From 412dafd104324f234d7272ce287b4c05f1d0e557 Mon Sep 17 00:00:00 2001
From: shamalainen <sebastian@hamse.fi>
Date: Fri, 12 Mar 2021 11:25:32 +0200
Subject: [PATCH] Create functionality to link to tab element

---
 src/components/hy-tabs/hy-tabs.tsx | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/components/hy-tabs/hy-tabs.tsx b/src/components/hy-tabs/hy-tabs.tsx
index d4cb934d..b8fb9550 100644
--- a/src/components/hy-tabs/hy-tabs.tsx
+++ b/src/components/hy-tabs/hy-tabs.tsx
@@ -316,6 +316,16 @@ export class HyTabs implements ComponentInterface {
     const classComponentAttributes = ['hy-tabs__container', `hy-tabs__container__${this.headerstyle}`].join(' ');
     const id = this.tabId.toLowerCase().replace(/\W/g, '-');
 
+    if (window.location.hash) {
+      const tabHash = window.location.hash.substring(1);
+      const isUrlHashed = this.tabButtonTitles.some((tab) => tab['id'] === tabHash);
+
+      if (isUrlHashed) {
+        const hashElement = document.getElementById(tabHash);
+        if (hashElement) this.activateTab(hashElement, true);
+      }
+    }
+
     return [
       <hy-box pt="1.25, 1.25, 1.5, 2.5" />,
       <div id={id} class={classComponentAttributes}>
-- 
GitLab