rob-balfre / svelte-select

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

Select module inside {#each } loop triggers on:select event multiple times #468

Closed ghost closed 1 year ago

ghost commented 2 years ago

As demonstrated by the following repl there is an issue when the Select module is used inside a {#each } loop

https://svelte.dev/repl/23a5e5bca2fe496496d7de69e7279b90?version=3.50.1

Situation:

  1. Creating Select modules inside loop
  2. The Select module grab the value from the loop ({#each}) variable
  3. Changing the loop variable when selecting a new item will trigger the refresh of the Select module
  4. Unexpectedly we get a new on:select event call.
kl3sk commented 1 year ago

Hello,

A solution is to separate each select inside it's own component.

https://svelte.dev/repl/d2a69292f9d94ffba863556f56ef0df2?version=3.50.1