rob-balfre / svelte-select

Svelte Select. A select component for Svelte
https://svelte-select-examples.vercel.app
Other
1.26k stars 175 forks source link

v5: Can't select suggestions #395

Closed hmnd closed 2 years ago

hmnd commented 2 years ago

When selecting a suggestion, fitlerText seems to be reset to undefined, causing setupFilterText to error, and the component to freeze. See the stacktrace below: image

rob-balfre commented 2 years ago

Strange doesn't happen in my tests or the REPL... but looks like a valid bug.

https://svelte.dev/repl/7f0f9f3a64c04567b1ae8513383fd046?version=3.47.0

rob-balfre commented 2 years ago

@hmnd what version of svelte are you running?

hmnd commented 2 years ago

@rob-balfre ah, I'm using objects for suggestions like so: https://svelte.dev/repl/0e27b81c0c414c7c8ed1cd899fe290a7?version=3.47.0. Are they not supposed to work like that?

I'm on v3.47.0 too.

rob-balfre commented 2 years ago

Suggestions is just an array of strings to populate 'filterText' on click. Maybe the docs aren't very clear.

hmnd commented 2 years ago

Ahh ok. I was able to implement the behavior I was looking for by flipping between providing pre-loaded items and loadOptions depending on whether there is active filterText. Probably better as a separate issue, but would be great if there was a preload setting to allow loading initial options by calling loadOptions without a search value.

Docs (and ts types) might be a little clearer if the type was explicitly string[] instead of array.

rob-balfre commented 2 years ago

I've added string[] to the docs for suggestions. Thanks.