Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions apps/web/components/documents-command-palette.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,16 @@
for (const a of actions) items.push(a)
}

// Reset selection on items change
// biome-ignore lint/correctness/useExhaustiveDependencies: search is the trigger — snap the selection back to the top result whenever the query changes
useEffect(() => {
setSelectedIndex(0)
}, [])
}, [search])

// Keep the selection in range when the list shrinks (async results
// replacing recent docs, refetches, etc.)
useEffect(() => {
setSelectedIndex((i) => Math.min(i, Math.max(items.length - 1, 0)))
}, [items.length])

// Scroll selected into view
useEffect(() => {
Expand Down Expand Up @@ -252,7 +258,7 @@
if (item) handleSelect(item)
}
},
[items, selectedIndex, handleSelect],

Check warning on line 261 in apps/web/components/documents-command-palette.tsx

View workflow job for this annotation

GitHub Actions / Quality Checks

lint/correctness/useExhaustiveDependencies

items changes on every re-render and should not be used as a hook dependency.
)

function renderItem(item: PaletteItem, index: number) {
Expand Down
Loading