From 2ea3ca1a07cff46f00e662c236d54c7d1f4ec61b Mon Sep 17 00:00:00 2001 From: wukko Date: Mon, 17 Jun 2024 00:31:07 +0600 Subject: [PATCH] web/sidebar: automatically scroll to active tab --- web/src/components/sidebar/SidebarTab.svelte | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/web/src/components/sidebar/SidebarTab.svelte b/web/src/components/sidebar/SidebarTab.svelte index 36b50f6c..87bf8cd0 100644 --- a/web/src/components/sidebar/SidebarTab.svelte +++ b/web/src/components/sidebar/SidebarTab.svelte @@ -4,7 +4,19 @@ export let tabName: string; export let tabLink: string; + let tab: HTMLElement; + $: isTabActive = $page.url.pathname === tabLink; + + const showTab = (e: HTMLElement | undefined) => { + if (e) { + e.scrollIntoView({}); + } + } + + $: if (isTabActive) { + showTab(tab) + } showTab(tab)} > {tabName}