Skip to content

svelte-select Displays Undefined for Numeric Values #662

@georgeemr

Description

@georgeemr

Problem: The svelte-select component is not displaying the selected item correctly when the items prop is an array of objects with numeric values. However, it works as expected with string values. When using numeric values, the selected item shows "undefined" instead of the correct label.

Expected Behavior: Irrespective of the data type of the value field in the items array (string or numeric), the svelte-select component should display the label of the selected item correctly.

Steps to Reproduce:
Use the svelte-select component with an items array having numeric values for the value field.
Two ways to reproduce it:
• When the item is set on the OnMount (for example if i'm loading a model from a API) notice that the component displays "undefined" for the selected item.
• If you search the value, then select it, it shows undefined too. If you don't search, just select it from the list, it works.

Sample Code:
https://svelte.dev/repl/f203e41b174441a1a217216ce01b0099?version=4.2.8

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