From 9bbc7698a96772057053558d1a67b83ca34c76ef Mon Sep 17 00:00:00 2001 From: Daniel Miedzik Date: Thu, 18 Nov 2021 16:45:47 +0100 Subject: [PATCH] Fix: Tabs dispatch change event on init (#882) * fix tabs on change problem * fix(tabs): dispatch change event in update/change context methods Co-authored-by: metonym --- src/Tabs/Tabs.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Tabs/Tabs.svelte b/src/Tabs/Tabs.svelte index 7ff549f7..b844066e 100644 --- a/src/Tabs/Tabs.svelte +++ b/src/Tabs/Tabs.svelte @@ -52,6 +52,7 @@ }, update: (id) => { currentIndex = $tabsById[id].index; + dispatch("change", currentIndex); }, change: (direction) => { let index = currentIndex + direction; @@ -77,6 +78,7 @@ } currentIndex = index; + dispatch("change", currentIndex); }, }); @@ -91,8 +93,6 @@ $: currentTab = $tabs[currentIndex] || undefined; $: currentContent = $content[currentIndex] || undefined; $: { - dispatch("change", currentIndex); - if (currentTab) { selectedTab.set(currentTab.id); }