From d55ea1576318140879d4dc3414836f93d17ebf03 Mon Sep 17 00:00:00 2001 From: TeshuKatepalli Date: Thu, 26 Oct 2023 19:15:09 +0530 Subject: [PATCH] fixed the header issues --- blocks/header/header.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/blocks/header/header.js b/blocks/header/header.js index a457eb4d..6b7b0cc4 100644 --- a/blocks/header/header.js +++ b/blocks/header/header.js @@ -116,14 +116,19 @@ function addClassesToMenuItems(element, depth) { const item = childItems[i]; // Add class to the immediate child element item.classList.add('hs-menu-item', `hs-menu-depth-${depth}`); + const strong = item.querySelector('strong'); + const link = item.querySelector('a'); + if (strong) { + link.setAttribute('href', '#'); + link.addEventListener('click', (event) => { + event.preventDefault(); + }); + } const em = item.querySelector('em'); - // Check if the href matches the current domain - const link = item.querySelector('a'); if (em) { link.setAttribute('target', '_blank'); - item.appendChild(link); } if (link && link.href === window.location.href) { item.classList.add('active'); @@ -146,6 +151,8 @@ function addClassesToMenuItems(element, depth) { }); } item.prepend(spanElement); + item.appendChild(link); + item.appendChild(childElement); const nextDepth = depth + 1; addClassesToMenuItems(childElement, nextDepth); }