Skip to content

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

Open
@YesWeDont

Description

@YesWeDont

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions