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

InputChips subscribe twice to passed in store #1759

Closed
Sarenor opened this issue Jul 18, 2023 · 0 comments · Fixed by #1768
Closed

InputChips subscribe twice to passed in store #1759

Sarenor opened this issue Jul 18, 2023 · 0 comments · Fixed by #1768
Labels
bug Something isn't working

Comments

@Sarenor
Copy link
Contributor

Sarenor commented Jul 18, 2023

Current Behavior

If a store is used as a component value, input chips currently subscribes twice to it.
Once, to set the value to the internal hidden Select, and once for it's other logi.

If people use a fancy store that might do API requests or similar, this could lead to problems where the API is called twice or logic is fired twice that shouldn't be called twice.

This might also affect other components with a hidden select like the ListBoxes.

Relevant Discord link:
https://discord.com/channels/1003691521280856084/1130244031859925152

Expected Behavior

Components should subscribe to passed in store values only once.

Steps To Reproduce

  1. Using input chips
<InputChip bind:value={$inputChipWritable}/>
  1. Pass in a store with this setup:
const inputChipWritable: Writable<string[]> = writable([]);
    inputChipWritable.subscribe((value) => {
        console.log("sub input");
    });

The console log will be triggered twice

Link to Reproduction / Stackblitz

No response

More Information

No response

@Sarenor Sarenor added the bug Something isn't working label Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant