mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-16 19:01:05 +00:00
fix(tab): set selected to currentIndex after updating
This commit is contained in:
parent
88ee01184b
commit
62719c45cc
1 changed files with 6 additions and 2 deletions
|
@ -8,7 +8,7 @@
|
|||
export let triggerHref = '#';
|
||||
export let type = 'default';
|
||||
|
||||
import { createEventDispatcher, setContext } from 'svelte';
|
||||
import { createEventDispatcher, afterUpdate, setContext } from 'svelte';
|
||||
import { writable, derived } from 'svelte/store';
|
||||
import ChevronDownGlyph from 'carbon-icons-svelte/lib/ChevronDownGlyph';
|
||||
import { cx } from '../../lib';
|
||||
|
@ -62,10 +62,14 @@
|
|||
}
|
||||
});
|
||||
|
||||
afterUpdate(() => {
|
||||
selected = currentIndex;
|
||||
});
|
||||
|
||||
$: currentIndex = selected;
|
||||
$: currentTab = $tabs[currentIndex] || undefined;
|
||||
$: currentContent = $content[currentIndex] || undefined;
|
||||
$: {
|
||||
selected = currentIndex;
|
||||
dispatch('change', currentIndex);
|
||||
|
||||
if (currentTab) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue