From 4c4f0cff5e29e1feef507f3ba400aa448e05ea53 Mon Sep 17 00:00:00 2001 From: Daniel Miedzik Date: Fri, 29 Oct 2021 11:22:46 +0200 Subject: [PATCH] fix tabs on change problem --- src/Tabs/Tabs.svelte | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Tabs/Tabs.svelte b/src/Tabs/Tabs.svelte index 3b8e625d..06098f74 100644 --- a/src/Tabs/Tabs.svelte +++ b/src/Tabs/Tabs.svelte @@ -46,7 +46,10 @@ content.update((_) => [..._, { ...data, index: _.length }]); }, update: (id) => { - currentIndex = $tabsById[id].index; + if (currentIndex !== $tabsById[id].index) { + currentIndex = $tabsById[id].index; + dispatch("change", currentIndex); + } }, change: (direction) => { let index = currentIndex + direction; @@ -86,8 +89,6 @@ $: currentTab = $tabs[currentIndex] || undefined; $: currentContent = $content[currentIndex] || undefined; $: { - dispatch("change", currentIndex); - if (currentTab) { selectedTab.set(currentTab.id); }