Open horakmar opened 2 months ago
<Autocomplete bind:highlightedItem={hItem} ... />
When you highlight first item in list, hItem is set to null.
hItem
null
It's because highlightIndex is 0 in this expression:
highlightIndex
$: highlightedItem = filteredListItems && highlightIndex && highlightIndex >= 0 && highlightIndex < filteredListItems.length ? filteredListItems[highlightIndex].item : null;
I suggest this patch:
diff --git a/src/SimpleAutocomplete.svelte b/src/SimpleAutocomplete.svelte index 3b27caf..e7275a6 100644 --- a/src/SimpleAutocomplete.svelte +++ b/src/SimpleAutocomplete.svelte @@ -344,7 +344,7 @@ $: highlightedItem = filteredListItems && - highlightIndex && + highlightIndex !== undefined && highlightIndex >= 0 && highlightIndex < filteredListItems.length ? filteredListItems[highlightIndex].item
When you highlight first item in list,
hItem
is set tonull
.It's because
highlightIndex
is 0 in this expression:I suggest this patch: