Skip to content

Commit

Permalink
fix select multiple
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte committed Dec 2, 2023
1 parent 695721f commit 9659611
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/demos/select-demo.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<Select.Root>
<Select.Trigger
class="inline-flex h-input w-[296px] items-center rounded-9px border border-border-input bg-background px-[11px] text-sm transition-colors placeholder:text-foreground-alt/50 focus:outline-none focus:ring-2 focus:ring-foreground focus:ring-offset-2 focus:ring-offset-background "
class="inline-flex h-input w-[296px] items-center rounded-9px border border-border-input bg-background px-[11px] text-sm transition-colors placeholder:text-foreground-alt/50 focus:outline-none focus:ring-2 focus:ring-foreground focus:ring-offset-2 focus:ring-offset-background"
aria-label="Select a theme"
>
<Palette class="mr-[9px] text-muted-foreground sq-6" />
Expand Down
17 changes: 13 additions & 4 deletions src/lib/bits/select/components/select.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,16 @@
name,
multiple: multiple as Multiple,
forceVisible: true,
defaultSelected: selected,
defaultSelected: Array.isArray(selected)
? ([...selected] as $$Props["selected"])
: selected,
defaultOpen: open,
onSelectedChange: ({ next }) => {
if (Array.isArray(next)) {
onSelectedChange?.(next);
selected = next;
if (JSON.stringify(next) !== JSON.stringify(selected)) {
onSelectedChange?.(next);
selected = next;
}
return next;
}
Expand Down Expand Up @@ -82,7 +86,12 @@
);
$: open !== undefined && localOpen.set(open);
$: selected !== undefined && localSelected.set(selected);
$: selected !== undefined &&
localSelected.set(
Array.isArray(selected)
? ([...selected] as $$Props["selected"])
: selected
);
$: updateOption("required", required);
$: updateOption("disabled", disabled);
Expand Down

0 comments on commit 9659611

Please sign in to comment.