mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
fix(tabs): dispatch "change" event only if index has changed (#1279)
Fixes #1278
This commit is contained in:
parent
2cc54c1a53
commit
9911764df1
1 changed files with 7 additions and 2 deletions
|
@ -52,7 +52,6 @@
|
||||||
},
|
},
|
||||||
update: (id) => {
|
update: (id) => {
|
||||||
currentIndex = $tabsById[id].index;
|
currentIndex = $tabsById[id].index;
|
||||||
dispatch("change", currentIndex);
|
|
||||||
},
|
},
|
||||||
change: (direction) => {
|
change: (direction) => {
|
||||||
let index = currentIndex + direction;
|
let index = currentIndex + direction;
|
||||||
|
@ -78,16 +77,22 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
currentIndex = index;
|
currentIndex = index;
|
||||||
dispatch("change", currentIndex);
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
afterUpdate(() => {
|
afterUpdate(() => {
|
||||||
selected = currentIndex;
|
selected = currentIndex;
|
||||||
|
|
||||||
|
if (prevIndex > -1 && prevIndex !== currentIndex) {
|
||||||
|
dispatch("change", currentIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
prevIndex = currentIndex;
|
||||||
});
|
});
|
||||||
|
|
||||||
let dropdownHidden = true;
|
let dropdownHidden = true;
|
||||||
let currentIndex = selected;
|
let currentIndex = selected;
|
||||||
|
let prevIndex = -1;
|
||||||
|
|
||||||
$: currentIndex = selected;
|
$: currentIndex = selected;
|
||||||
$: currentTab = $tabs[currentIndex] || undefined;
|
$: currentTab = $tabs[currentIndex] || undefined;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue