Improve file picker UX: inline chips, focus preservation, escape behavior
- Move attachment chips inside textarea wrapper (appears inline) - Keep textarea focused when pressing Escape (no focus stealing) - Track ignored @ positions after Escape to prevent re-triggering picker - Clear ignored positions on message send - Use capture phase for Escape key handling (true flag on addEventListener) - Escape now works like email: type @example.com naturally after dismissing picker - Chips show above textarea input with better spacing (pt-2 pb-1)
This commit is contained in:
@@ -174,6 +174,14 @@ const FilePicker: Component<FilePickerProps> = (props) => {
|
||||
const listener = (e: KeyboardEvent) => {
|
||||
if (!props.open) return
|
||||
const fileList = files()
|
||||
|
||||
if (e.key === "Escape") {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
props.onClose()
|
||||
return
|
||||
}
|
||||
|
||||
if (fileList.length === 0) return
|
||||
|
||||
if (e.key === "ArrowDown") {
|
||||
@@ -189,14 +197,11 @@ const FilePicker: Component<FilePickerProps> = (props) => {
|
||||
if (fileList[selectedIndex()]) {
|
||||
handleSelect(fileList[selectedIndex()].path)
|
||||
}
|
||||
} else if (e.key === "Escape") {
|
||||
e.preventDefault()
|
||||
props.onClose()
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener("keydown", listener)
|
||||
onCleanup(() => document.removeEventListener("keydown", listener))
|
||||
document.addEventListener("keydown", listener, true)
|
||||
onCleanup(() => document.removeEventListener("keydown", listener, true))
|
||||
})
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user