Skip to content

Simple arrays converted to objects #726

@ianengelbrecht

Description

@ianengelbrecht

May I ask the reason that arrays of primitive values are converted to arrays of { value:value label:value }? From the simple example:

<script> import Select from 'svelte-select'; let items = ['One', 'Two', 'Three']; let value = null; </script>

<Select {items} bind:value />

{#if value}

Selected value: {value.label}

{/if}

It would be simpler if I could do:

Selected value: {value}

My actual use case is binding the value of Select to an array property of an object:

<script> import Select from 'svelte-select'; let items = ['One', 'Two', 'Three']; const myData = { arr: ['One', 'Three'] }; </script>

<Select {items} bind:value={myData.arr}/>

Selected value: {myData.arr.join('|')}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions