pstanoev / simple-svelte-autocomplete

Simple Autocomplete / typeahead component for Svelte
http://simple-svelte-autocomplete.surge.sh/
MIT License
469 stars 79 forks source link

Fix for missmatch of selected and available items #115 #116

Closed nika-d closed 3 years ago

nika-d commented 3 years ago

Fix for #115

The pull request changes the order of reactive $: statements.

Before the control flow was:

line 181 $: selectedItem, onSelectedItemChanged(); // filter options list - the old one! <- wrong! 
line 299 $: items, prepareListItems(); // set the new options list

The change in the pull request:

line 275 $: items, prepareListItems(); // set the new options list
line 285 $: selectedItem, onSelectedItemChanged(); // filter the new options list

Tests are provided, too.

pstanoev commented 3 years ago

Many thanks for the code, I see now that by switching the order the issue is fixed. I've pushed a fix based on the code from this PR. I will close this, please merge back from the main branch.