rob-balfre / svelte-select

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

Unable to change second bound element after making a selection #506

Closed NimbusDigital closed 1 year ago

NimbusDigital commented 1 year ago

Great component!

I've run into a problem. I'm relatively new to Svelte, so not sure if it's expected behaviour...

See: https://svelte.dev/repl/b48e98c343c949f99f8c59d965eaa0e9?version=3.55.0

I am unable to change the value of the second drop-down after selecting a value in the Svelte Select component:

When using a regular select element, the second element can be bound and changed. It's only the Svelte Select component that exhibits this behaviour.

rob-balfre commented 1 year ago

@NimbusDigital you needed a unique key in your labels and to tell svelte-select using itemId.

see: https://svelte.dev/repl/947f3bc0f01d4a319eb7740188d6d27b?version=3.55.0

NimbusDigital commented 1 year ago

Thanks @rob-balfre,

I see you've used the 'code' property as itemId in your REPL fork. Unfortunately, the problem persists - the value in the second drop-down cannot be changed after the initial label is selected.

I see this also happens when using native elements... https://svelte.dev/repl/a7d2182393ba49d78d7287b321d6fa8e?version=3.55.0

So, I appreciate it's not a bug in Svelte Select. However, I have written another native implementation using the Label object's index. Is it possible to retrieve the index value from Svelte Select (or is there another way to do this)?... https://svelte.dev/repl/b43cb18e93cc4fd5ab427485ab1c3abe?version=3.55.0

Many thanks,

Mark

rob-balfre commented 1 year ago

@NimbusDigital you can't bind values to reactive statements...

https://svelte.dev/repl/7f1f34f0da794f40a71435794fd5d621?version=3.55.0