From 5a56373d3a1ff7b3d44346c531419fac6adcffeb Mon Sep 17 00:00:00 2001 From: kleinbem Date: Wed, 11 Nov 2026 03:12:26 +0000 Subject: [PATCH] fix(ui): pointer-driven palette focus doesn't scroll the list CodeRabbit on #10 (outside the diff): focusing a partly visible result on mousemove could scroll another result under the cursor. Co-Authored-By: Claude Opus 5.5 --- src/lib/components/CommandPalette.svelte | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/components/CommandPalette.svelte b/src/lib/components/CommandPalette.svelte index b8b6f23..f8e168c 100644 --- a/src/lib/components/CommandPalette.svelte +++ b/src/lib/components/CommandPalette.svelte @@ -76,11 +76,12 @@ }); // When a result link has focus, move focus with the highlight so Enter opens the highlighted one. - async function followSelection() { + // Pointer moves pass preventScroll, so the list doesn't slide another result under the cursor. + async function followSelection(preventScroll = false) { const active = document.activeElement; if (!(active instanceof HTMLAnchorElement) || !dialogEl?.contains(active)) return; await tick(); - dialogEl.querySelectorAll('a[data-result]')[selectedIndex]?.focus(); + dialogEl.querySelectorAll('a[data-result]')[selectedIndex]?.focus({ preventScroll }); } // Keep Tab inside the open dialog. @@ -271,7 +272,7 @@ // mousemove, not mouseenter: scrolling under a still pointer fires enter only. if (selectedIndex === index) return; selectedIndex = index; - followSelection(); + followSelection(true); }} onfocus={() => (selectedIndex = index)} onclick={() => (open = false)}