rob-balfre / svelte-select

Svelte Select. A select component for Svelte
https://svelte-select-examples.vercel.app
Other
1.25k stars 175 forks source link

V5: Initial Value not set if value of itemId is numeric #503

Closed yoh-extradat closed 1 year ago

yoh-extradat commented 1 year ago
<script>
const Items = [
    {value: 1, label: 'Chocolate'},
    {value: 2, label: 'Pizza'},
    {value: 3, label: 'Cake'},
    {value: 4, label: 'Chips'},
    {value: 5, label: 'Ice Cream'}
];
</script>
<Select items={Items} value={1}></Select>

Result

Screenshot 2022-12-08 at 13 54 21
Maadtin commented 1 year ago

I think your value should be value={{ value: 1, label: 'Chocolate'}}

georgeemr commented 5 months ago

I'm having this issue and cannot resolve it, just if the id is string. How can I resolve it using the Ids numeric.

My datasource is numeric, and with a normal select it just works: https://svelte.dev/repl/f203e41b174441a1a217216ce01b0099?version=4.2.8