You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
<select> needs two clicks when used with remote functions form #15835
When using a select within a remote functions form, clicking an option will not select the clicked option but the select will show empty instead. I need to click the same option again, only then is the option properly selected.
When I remove {...submitSelection} from the form element it works fine.
Reproduces on main, and it comes down to the option value type rather than anything remote-functions-specific.
.as('select') controls the select with a string (form data is always strings), but the options here use numeric values (<option value={option.id}>). A string never === the number an <option value={2}> stores, so on the first change the controlled value matches no option and the select reverts to empty. It only sticks on the second change because the value stops changing and Svelte stops re-applying it, which is the "two clicks."
I reduced it away from remote functions to confirm:
a plain <select value={x} onchange={(e) => (x = e.currentTarget.value)}> with numeric options two-clicks identically (x ends up the string "2"), while bind:value with the same options works first try because it preserves the number.
in the remote form, .as('select') selects on the first pick as soon as the option values are strings (value="1").
So the app-side fix is string option values (or coercing to match the field type), since .as('select') is necessarily string-typed.
The thing that makes this so confusing is that no dev warning is emitted in any of these cases. Might be worth a Svelte warning when a <select>'s value matches no option, since the silent revert-then-accept is the surprising part.
Activity
Nic-Polumeyv commentedon Jun 7, 2026
Reproduces on
main, and it comes down to the option value type rather than anything remote-functions-specific..as('select')controls the select with a string (form data is always strings), but the options here use numeric values (<option value={option.id}>). A string never===the number an<option value={2}>stores, so on the first change the controlled value matches no option and the select reverts to empty. It only sticks on the second change because the value stops changing and Svelte stops re-applying it, which is the "two clicks."I reduced it away from remote functions to confirm:
<select value={x} onchange={(e) => (x = e.currentTarget.value)}>with numeric options two-clicks identically (xends up the string"2"), whilebind:valuewith the same options works first try because it preserves the number..as('select')selects on the first pick as soon as the option values are strings (value="1").So the app-side fix is string option values (or coercing to match the field type), since
.as('select')is necessarily string-typed.The thing that makes this so confusing is that no dev warning is emitted in any of these cases. Might be worth a Svelte warning when a
<select>'s value matches no option, since the silent revert-then-accept is the surprising part.