mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 18:31:06 +00:00
feat(multi-select): dispatch "select" event
This commit is contained in:
parent
a016bf897c
commit
2140eebb33
3 changed files with 25 additions and 11 deletions
|
@ -153,7 +153,7 @@
|
|||
* @typedef {{ id: MultiSelectItemId; text: MultiSelectItemText; }} MultiSelectItem
|
||||
*/
|
||||
|
||||
import { afterUpdate, setContext } from "svelte";
|
||||
import { afterUpdate, createEventDispatcher, setContext } from "svelte";
|
||||
import WarningFilled16 from "carbon-icons-svelte/lib/WarningFilled16";
|
||||
import { Checkbox } from "../Checkbox";
|
||||
import {
|
||||
|
@ -165,6 +165,8 @@
|
|||
ListBoxSelection,
|
||||
} from "../ListBox";
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
let multiSelectRef = null;
|
||||
let fieldRef = null;
|
||||
let selectionRef = null;
|
||||
|
@ -213,6 +215,11 @@
|
|||
}
|
||||
prevChecked = checked;
|
||||
selectedIds = checked.map(({ id }) => id);
|
||||
dispatch("select", {
|
||||
selectedIds,
|
||||
selected: checked,
|
||||
unselected: unchecked,
|
||||
});
|
||||
}
|
||||
|
||||
if (!open) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue