diff --git a/src/components/hy-tabs/hy-tabs.tsx b/src/components/hy-tabs/hy-tabs.tsx index d4cb934d03ad5ff3d295a29cd218396157f6da97..b8fb95501c982e72261e8a93148cf3efd9674a01 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}>