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

Issues with functional bind:value for <select> #15331

Open
YesWeDont opened this issue Feb 18, 2025 · 1 comment
Open

Issues with functional bind:value for <select> #15331

YesWeDont opened this issue Feb 18, 2025 · 1 comment

Comments

@YesWeDont
Copy link

YesWeDont commented Feb 18, 2025

Describe the bug

  1. When a the value of a <select> tag is bound to a constant value via a bind:value={()=>constant, ()=>{}}, its value is still changeable
  2. The set handler is not always called when needed.

Reproduction

Reproduction uploaded to playground link: https://svelte.dev/playground/6b0d204844dd4adfba43f0f8858647e5?version=5.20.1

Bug 1: We can see this the case when we try to change values of the last three <select>s without changing the value of the first one
Bug 2: On the first select, I set bind:value={()=>selected, newValue=>selected=(newValue+2)}. See logs for the procedure I took to find the bug.

Logs

Logs for Bug 2:
[Initally, I set the select to One, and it results in the final value being Three. This is to avoid the bug interfering with itself.]
[I click 'Zero']
Event oninput
setter called with snew 0
Event onchange
[As expected, the first two <select>s update to Two.]
[I click 'Two' again and nothing happens - not even the event handlers fire, but I expect the value to be 'Four'.]
[I click 'Zero' again]
Event oninput
setter called with snew 0
Event onchange
[I expect both fields to be 'Two' but the first field is set to 'Zero' for some reason. The second field is unchanged.]

System Info

Mozilla Firefox 135.0-1 on Linux Mint 22 "Wilma", kernel version 6.8.0-51-generic

Severity

annoyance

@dummdidumm
Copy link
Member

Generally, inputs are "uncontrolled", i.e. you cannot block events like that. Now with function bindings, the question is whether or not they should be blockable in that case. I lean towards no, but keeping this open for discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants