Open notramo opened 1 year ago
NativeSelect uses the <select />
element. As such, it cannot support data types other than string. We should enforce string values even when using objects, or just keep the coercion. Mantine's version also has the same limitation.
The upcoming Select component is probably what you need if the value type is important.
Edit:
Looks like I might be wrong about that, as far as Svelte is concerned. https://svelte.dev/tutorial/select-bindings
The note indicates that in Svelte, <select />
is fine with non-string values.
It's not yet clear if this is something we want to do so this has been left in the backlog for now. Svelte allows it, so it's definitely something we could change
This is really annoying. If the API provides a number in an object property, we can't use bind:value
, so we have to use value={product.price}
and on:change={event => product.price = parseInt(event.target.value)}
.
What package has an issue
@svelteuidev/core
A clear and concise description of what the bug is
When using
bind:value
withNativeSelect
, the assigned value is always astring
. E.g. thedata
property contains this entry:[{ label: 'one', value: 1 }, { label: 'two', value: 2 }]
. One would expect that when the "one" option is selected, the assigned value will be1
(number), but it's"1"
(string) instead.