Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MultiSelect] on:change is triggered twice #1337

Open
freearhey opened this issue May 1, 2024 · 2 comments · May be fixed by #1341
Open

[MultiSelect] on:change is triggered twice #1337

freearhey opened this issue May 1, 2024 · 2 comments · May be fixed by #1341

Comments

@freearhey
Copy link

Describe the bug

The change event is triggered twice in a row.

Reproduction

<script>
  import { MultiSelect } from 'flowbite-svelte';

  let selected = [];
  let countries = [
    { value: 'us', name: 'United States' },
    { value: 'ca', name: 'Canada' },
    { value: 'fr', name: 'France' },
    { value: 'jp', name: 'Japan' },
    { value: 'en', name: 'England' }
  ];
</script>

<MultiSelect items={countries} bind:value={selected} on:change={() => console.log('triggered')} />
```[](url)

### Flowbite version and System Info

```shell
Node: 18.18.2
npm: 10.5.2
@sveltejs/kit: 2.0.0
flowbite-svelte: 0.46.1
svelte: 4.2.7
vite: 5.0.3
@jumtp
Copy link
Contributor

jumtp commented May 2, 2024

Unable to reproduce this bug. can you provide a link to a repo that can reproduce the problem you ran into? Use this Stackblitz template to add your code.

@freearhey freearhey reopened this May 3, 2024
@freearhey
Copy link
Author

It turns out that the bug only appears if you nest MultiSelect in some other component, in my case it was Sidebar:

<Sidebar>
  <MultiSelect items={countries} bind:value={selected} on:change={() => console.log('triggered')} />
</Sidebar>

Reproduction: https://stackblitz.com/edit/sveltejs-kit-template-default-fodah2?file=src%2Froutes%2F%2Bpage.svelte

@jumtp jumtp linked a pull request May 6, 2024 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants