mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-20 20:33: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
|
### Events
|
||||||
|
|
||||||
| Event name | Type | Detail |
|
| Event name | Type | Detail |
|
||||||
| :--------- | :--------- | :--------------------------------------------------------------------------------------------- |
|
| :--------- | :--------- | :---------------------------------------------------------------------- |
|
||||||
| select | dispatched | <code>{ selectedId: DropdownItemId, selectedIndex: number, selectedItem: DropdownItem }</code> |
|
| select | dispatched | <code>{ selectedId: DropdownItemId, selectedItem: DropdownItem }</code> |
|
||||||
|
|
||||||
## `DropdownSkeleton`
|
## `DropdownSkeleton`
|
||||||
|
|
||||||
|
|
|
@ -3228,7 +3228,7 @@
|
||||||
{
|
{
|
||||||
"type": "dispatched",
|
"type": "dispatched",
|
||||||
"name": "select",
|
"name": "select",
|
||||||
"detail": "{ selectedId: DropdownItemId, selectedIndex: number, selectedItem: DropdownItem }"
|
"detail": "{ selectedId: DropdownItemId, selectedItem: DropdownItem }"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"typedefs": [
|
"typedefs": [
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* @typedef {string} DropdownItemId
|
* @typedef {string} DropdownItemId
|
||||||
* @typedef {string} DropdownItemText
|
* @typedef {string} DropdownItemText
|
||||||
* @typedef {{ id: DropdownItemId; text: DropdownItemText; }} DropdownItem
|
* @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) {
|
$: if (selectedId !== undefined) {
|
||||||
dispatch("select", { selectedId, selectedIndex, selectedItem });
|
dispatch("select", { selectedId, selectedItem });
|
||||||
}
|
}
|
||||||
$: inline = type === "inline";
|
$: inline = type === "inline";
|
||||||
$: selectedIndex = items.findIndex((item) => item.id === selectedId);
|
$: selectedItem = items.find((item) => item.id === selectedId);
|
||||||
$: selectedItem = items[selectedIndex];
|
|
||||||
$: if (!open) {
|
$: if (!open) {
|
||||||
highlightedIndex = -1;
|
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<{
|
select: CustomEvent<{
|
||||||
selectedId: DropdownItemId;
|
selectedId: DropdownItemId;
|
||||||
selectedIndex: number;
|
|
||||||
selectedItem: DropdownItem;
|
selectedItem: DropdownItem;
|
||||||
}>;
|
}>;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue