mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-20 12:23:02 +00:00
feat: omit selectedIndex
from the select
event
This commit is contained in:
parent
aa6396f02a
commit
d52828a25c
4 changed files with 7 additions and 9 deletions
|
@ -1193,8 +1193,8 @@ None.
|
|||
### Events
|
||||
|
||||
| Event name | Type | Detail |
|
||||
| :--------- | :--------- | :--------------------------------------------------------------------------------------------- |
|
||||
| select | dispatched | <code>{ selectedId: DropdownItemId, selectedIndex: number, selectedItem: DropdownItem }</code> |
|
||||
| :--------- | :--------- | :---------------------------------------------------------------------- |
|
||||
| select | dispatched | <code>{ selectedId: DropdownItemId, selectedItem: DropdownItem }</code> |
|
||||
|
||||
## `DropdownSkeleton`
|
||||
|
||||
|
|
|
@ -3228,7 +3228,7 @@
|
|||
{
|
||||
"type": "dispatched",
|
||||
"name": "select",
|
||||
"detail": "{ selectedId: DropdownItemId, selectedIndex: number, selectedItem: DropdownItem }"
|
||||
"detail": "{ selectedId: DropdownItemId, selectedItem: DropdownItem }"
|
||||
}
|
||||
],
|
||||
"typedefs": [
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* @typedef {string} DropdownItemId
|
||||
* @typedef {string} DropdownItemText
|
||||
* @typedef {{ id: DropdownItemId; text: DropdownItemText; }} DropdownItem
|
||||
* @event {{ selectedId: DropdownItemId, selectedIndex: number, selectedItem: DropdownItem }} select
|
||||
* @event {{ selectedId: DropdownItemId, selectedItem: DropdownItem }} select
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -126,11 +126,10 @@
|
|||
}
|
||||
|
||||
$: if (selectedId !== undefined) {
|
||||
dispatch("select", { selectedId, selectedIndex, selectedItem });
|
||||
dispatch("select", { selectedId, selectedItem });
|
||||
}
|
||||
$: inline = type === "inline";
|
||||
$: selectedIndex = items.findIndex((item) => item.id === selectedId);
|
||||
$: selectedItem = items[selectedIndex];
|
||||
$: selectedItem = items.find((item) => item.id === selectedId);
|
||||
$: if (!open) {
|
||||
highlightedIndex = -1;
|
||||
}
|
||||
|
|
1
types/Dropdown/Dropdown.svelte.d.ts
vendored
1
types/Dropdown/Dropdown.svelte.d.ts
vendored
|
@ -145,7 +145,6 @@ export default class Dropdown extends SvelteComponentTyped<
|
|||
{
|
||||
select: CustomEvent<{
|
||||
selectedId: DropdownItemId;
|
||||
selectedIndex: number;
|
||||
selectedItem: DropdownItem;
|
||||
}>;
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue