This repository demonstrates a bug in svelte-multiselect that crashed a production application.
When options have labels that differ only by case (e.g., "pd" and "PD"), the component crashes immediately on mount - even when each option has a unique UUID in the value field.
Svelte error: each_key_duplicate
Keyed each block has duplicate key `pd` at indexes 0 and 1
git clone https://github.com/davidamacey/multiselect-case-bug-repro.git
cd multiselect-case-bug-repro
npm install
npm run dev
The demo shows three scenarios:
Uses key={(opt) => opt.value} to key by UUID. Allows "pd", "PD", and "Pd" as distinct selections.
Filters options to hide case variants after selection. Still uses UUID for keying.
Check the "Show buggy default behavior" checkbox - the page crashes immediately because the default key function lowercases all labels, causing "pd", "PD", and "Pd" to all have the key "pd".
In svelte-multiselect/src/lib/MultiSelect.svelte, line 29:
key = (opt) => `${utils.get_label(opt)}`.toLowerCase()
This:
value field entirely (even when it contains unique UUIDs){#each} blocks with duplicate keys<MultiSelect
{options}
key={(opt) => opt.value}
/>
See ISSUE.md for the full issue report and suggested fixes.