Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/polite-rivers-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte-ux': patch
---

Dispatch `apply` event when applying from MultiSelect
10 changes: 9 additions & 1 deletion packages/svelte-ux/src/lib/components/MultiSelect.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,17 @@
indeterminate: typeof $indeterminateStore;
original: { selected: MenuOption<TValue>[]; unselected: MenuOption<TValue>[] };
};
apply: {
value: typeof value;
selection: typeof $selection;
indeterminate: typeof $indeterminateStore;
original: { selected: MenuOption<TValue>[]; unselected: MenuOption<TValue>[] };
};
cancel: null;
}>();

export let onApply = async (ctx: {
value: typeof value;
selection: typeof $selection;
indeterminate: typeof $indeterminateStore;
original: { selected: MenuOption<TValue>[]; unselected: MenuOption<TValue>[] };
Expand All @@ -71,12 +78,13 @@
async function applyChange() {
applying = true;
const changeContext = {
value: $selection.selected,
value: $selection.selected as TValue[],
selection: $selection,
indeterminate: $indeterminateStore,
original: { selected: selectedOptions, unselected: unselectedOptions },
};
await onApply(changeContext);
dispatch('apply', changeContext);
applying = false;
onChange();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@
bind:open
on:change={onSelectChange}
on:close={hide}
on:apply
bind:menuOptionsEl
{...menuProps}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
on:cancel
on:change={() => mode !== 'immediate' && close()}
on:change
on:apply
>
<slot name="beforeOptions" slot="beforeOptions" let:selection {selection} />
<slot name="afterOptions" slot="afterOptions" let:selection {selection} />
Expand Down