pstanoev / simple-svelte-autocomplete

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

choice items updating too late #112

Closed nika-d closed 3 years ago

nika-d commented 3 years ago

Unexpected behavior: Let´s say, the autocomplete was already rendered once, with some list of possible choices in items. Everything fine so far. Now, when we change the selectedItem and the items, and then click into the autocomplete field, we see: autocomplete still uses the old value for the options! Also, as checked in Svelte Dev Tools, internal variable filteredListItems still shows the old items list, while listItems already hold new value. Here is a minimal example highlighting the weird behavior: https://github.com/nika-d/autocomplete-minimal-example Desired behavior: When items is set to a new array, this new options list shows up the very next time the autocomplete options dropdown opens. Maybe related: Just observed, that also the event handlers are not called properly as expected.

@pstanoev Hi! 🙂 Could you please verify, if this is a bug or a feature? Or maybe it´s just my wrong usage..? (You are invited as collaborator just in case you want to correct the example. )

nika-d commented 3 years ago

pull request for fix: https://github.com/pstanoev/simple-svelte-autocomplete/pull/113

pstanoev commented 3 years ago

Hi @nika-d, the described behavior is intended. There are other components which filters the list to single item after selection. This component was envisioned like the standard