-
Notifications
You must be signed in to change notification settings - Fork 181
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
Input type select behaves different than regular select #378
Comments
Hi @konrad-pawlus , this is kind of intentional/unavoidable, and a side effect of the way Svelte handles custom components. It works because you specified the order of the bind:value and on:change. If you reversed it would be consistent. Unfortunately we must specify some order in the custom component: https://github.com/bestguy/sveltestrap/blob/master/src/Input.svelte#L495 as Svelte does not allow you to pass on:events in restProps. This is related to: sveltejs/svelte#4616 |
Hi @bestguy , I created reply to show what I am observing: https://svelte.dev/repl/5c77db352e4d442bb3206d4ea676f865?version=3.42.4
Than do same with regular select. It works as expected. I understand that you specify this in an order, and see that issue on svelte is still open. Maybe changing order so bind happens first would be a temporary solution? |
That is an option, however there are people who use the on:change to do validation prior to setting value, etc. Might I ask what functionality you are trying to accomplish with on:change that requires the value and on:change to be in sync? |
I am just developing 2 simple selects, 2nd one options are populated on 1st one change. This can be accomplished exactly as described with vanilla Bootstrap. |
I'd normally use a computed that is derived from the first value, but can send a sample if that would help. |
I solved it by workaround using basic select instead of component. |
This component:
behaves differently than regular select:
when in reloadCategories there is a simple log:
console.log('Parent category', category.parent)
category value is printed as before binding.
In normal select this works properly, value is bind and function attached to on:change gets correct value.
Seams like Input calls on-change before value is bind.
The text was updated successfully, but these errors were encountered: