combobox: don't highlight first item on first open

This commit is contained in:
Elijah Duffy
2025-07-15 18:37:22 -07:00
parent c8a7c37635
commit 652c5632da
2 changed files with 18 additions and 2 deletions

View File

@@ -114,6 +114,7 @@
/** stores currently highlighted option (according to keyboard navigation or default item) */
let highlighted = $derived.by((): ComboboxOption | undefined => {
if (!searching) return undefined; // otherwise, the first item is highlighted on first open
if (filteredItems.length === 0) return undefined;
if (value !== undefined && filteredItems.find((v) => v.value === value?.value)) return value;
if (!filteredItems[0]?.disabled) return filteredItems[0];