From 774016ba11613777928d4c22ced934c518170280 Mon Sep 17 00:00:00 2001 From: Hibryda Date: Tue, 24 Mar 2026 12:54:58 +0100 Subject: [PATCH] fix(electrobun): remove read+write cycle in CommandPalette clamp selection --- ui-electrobun/src/mainview/CommandPalette.svelte | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ui-electrobun/src/mainview/CommandPalette.svelte b/ui-electrobun/src/mainview/CommandPalette.svelte index b4f7430..09dba29 100644 --- a/ui-electrobun/src/mainview/CommandPalette.svelte +++ b/ui-electrobun/src/mainview/CommandPalette.svelte @@ -88,11 +88,11 @@ } }); - // Clamp selection when filtered list changes - $effect(() => { + // Clamp selection when query changes (NOT via $effect — avoids read+write cycle) + function clampSelection() { const len = filtered.length; if (selectedIdx >= len) selectedIdx = Math.max(0, len - 1); - }); + } function handleKeydown(e: KeyboardEvent) { if (e.key === 'Escape') { onClose(); return; } @@ -138,6 +138,7 @@ placeholder={t('palette.placeholder')} bind:this={inputEl} bind:value={query} + oninput={() => clampSelection()} onkeydown={handleKeydown} aria-label="Command search" aria-autocomplete="list"