fix(electrobun): remove read+write cycle in CommandPalette clamp selection
This commit is contained in:
parent
b2b1e429dc
commit
774016ba11
1 changed files with 4 additions and 3 deletions
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue