From 7d765327490a8aea83f3fb29233a2c7e58c2c020 Mon Sep 17 00:00:00 2001 From: shamalainen <sebastian@hamse.fi> Date: Mon, 15 Mar 2021 10:17:05 +0200 Subject: [PATCH] Update anchor link automatic focus --- src/components/hy-tabs/hy-tabs.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/hy-tabs/hy-tabs.tsx b/src/components/hy-tabs/hy-tabs.tsx index b8fb9550..cdee93f3 100644 --- a/src/components/hy-tabs/hy-tabs.tsx +++ b/src/components/hy-tabs/hy-tabs.tsx @@ -322,7 +322,12 @@ export class HyTabs implements ComponentInterface { if (isUrlHashed) { const hashElement = document.getElementById(tabHash); - if (hashElement) this.activateTab(hashElement, true); + + if (hashElement) { + this.activateTab(hashElement, true); + const hashElementRect = hashElement.getBoundingClientRect(); + window.scrollTo({top: window.scrollY + hashElementRect.top - 200, behavior: 'smooth'}); + } } } -- GitLab