-
Notifications
You must be signed in to change notification settings - Fork 186
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
selectedValue is set to itself on load #208
Comments
svelte-select does some setup after mount. There is some some legacy code from v1 and v2 of Svelte that needs refactoring. This is a decent enough workaround ... |
Thank you, much appreciated. |
I've had to scrap using svelte-select due to this issue. I have a derived store based on the writable store I'm using for a form; the derived store reacts to every binding of a writable store attribute to a svelte-select component just instantiating the form. Every workaround I've tried just ends up producing ugly code and leaves me feeling like I'm fighting against svelte. I'll try to return to this myself when I get a chance, I just don't have the time for it atm. |
@mtrevor pretty sure now this is not an issue with svelte-select. It's important to understand that binding to a child component will fire a reactive statement. Native HTML form elements ( Here's an example that might help you... |
@mtrevor also this reply on discord might be of help ... |
@mtrevor can I ask you what alternative to svelte-select are you using? |
I have a writable store that sends updates to an API when modified. I'm binding properties of the store to
Select
components usingbind:selectedValue
. This immediately sets the bound property to the provided value, even before any user interaction has occurred. I'm using a half-dozen of these components in a form, so the store believes it has been modified 6 times before anything has actually changed.The problem isn't limited to stores: any bound
selectedValue
is immediately set to its contents when the component first loads.I've provided a REPL that reproduces this:
https://svelte.dev/repl/0653cdd1cabc45528c675cf8d4de5831?version=3.29.7
The text was updated successfully, but these errors were encountered: