Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/techniq/svelte-ux
Browse files Browse the repository at this point in the history
  • Loading branch information
techniq committed Jul 9, 2024
2 parents c5de38c + e8703ed commit 8ea2f99
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/tough-actors-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte-ux': patch
---

[SelectField] Fix options with object value due to non-unique {#each} keys
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
onKeyPress(e);
}}
>
{#each filteredOptions ?? [] as option, index (`${option.group}-${option.value}`)}
{#each filteredOptions ?? [] as option, index (JSON.stringify(option))}
{@const previousOption = filteredOptions[index - 1]}
{#if option.group && option.group !== previousOption?.group}
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,19 @@
/>
</Preview>

<h2>Object value options</h2>

<Preview>
<SelectField
options={[
{ label: 'Empty', value: null },
{ label: 'Foo', value: { id: 1 } },
{ label: 'Bar', value: { id: 2 } },
{ label: 'Baz', value: { id: 3 } },
]}
/>
</Preview>

<h2>Options with icons</h2>

<Preview>
Expand Down

0 comments on commit 8ea2f99

Please sign in to comment.