This commit is contained in:
Abhay Singh 2026-08-04 20:01:51 -07:00 • committed by GitHub
commit 0975bcffea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -199,10 +199,16 @@ export function DocumentsCommandPalette({
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(() => {