Fix file picker keyboard event handling and loading state

This commit is contained in:
Shantur Rathore
2025-10-24 00:52:17 +01:00
parent b6dc4ba249
commit f291649f74

View File

@@ -182,14 +182,17 @@ const FilePicker: Component<FilePickerProps> = (props) => {
if (e.key === "ArrowDown") { if (e.key === "ArrowDown") {
e.preventDefault() e.preventDefault()
e.stopPropagation()
handleNavigateDown() handleNavigateDown()
props.onNavigate("down") props.onNavigate("down")
} else if (e.key === "ArrowUp") { } else if (e.key === "ArrowUp") {
e.preventDefault() e.preventDefault()
e.stopPropagation()
handleNavigateUp() handleNavigateUp()
props.onNavigate("up") props.onNavigate("up")
} else if (e.key === "Enter") { } else if (e.key === "Enter") {
e.preventDefault() e.preventDefault()
e.stopPropagation()
if (fileList[selectedIndex()]) { if (fileList[selectedIndex()]) {
handleSelect(fileList[selectedIndex()].path) handleSelect(fileList[selectedIndex()].path)
} }
@@ -209,7 +212,7 @@ const FilePicker: Component<FilePickerProps> = (props) => {
> >
<div class="max-h-96 overflow-y-auto"> <div class="max-h-96 overflow-y-auto">
<Show <Show
when={!loading()} when={!loading() && isInitialized()}
fallback={ fallback={
<div class="p-4 text-center text-sm text-gray-500"> <div class="p-4 text-center text-sm text-gray-500">
<div class="inline-block h-4 w-4 animate-spin rounded-full border-2 border-gray-300 border-t-blue-600"></div> <div class="inline-block h-4 w-4 animate-spin rounded-full border-2 border-gray-300 border-t-blue-600"></div>