From 7a6c5e800635a70e548e29e080b35bba436487ea Mon Sep 17 00:00:00 2001 From: Tom Fleming Date: Thu, 23 Jul 2020 16:46:42 -0400 Subject: [PATCH] Revert "Revert "Removed closeSubMenu behavior - DP-19336"" This reverts commit ebbdb139d0da0927b4b88a0aa26f47c4e837cabd. --- .../assets/js/modules/mainNavHamburger.js | 35 ------------------- 1 file changed, 35 deletions(-) diff --git a/patternlab/styleguide/source/assets/js/modules/mainNavHamburger.js b/patternlab/styleguide/source/assets/js/modules/mainNavHamburger.js index 6a9b3c4e77..9520505cf5 100644 --- a/patternlab/styleguide/source/assets/js/modules/mainNavHamburger.js +++ b/patternlab/styleguide/source/assets/js/modules/mainNavHamburger.js @@ -119,15 +119,7 @@ if (null !== menuButton) { subItems.style.opacity = "0"; - itemButton.addEventListener("focus", function(e){ - closeSubMenus(item); - }); - itemButton.addEventListener("click", function (e) { - - closeSubMenus(item); - - if (item.classList.contains("submenu-open")) { item.classList.remove("submenu-open"); itemButton.setAttribute("aria-expanded", "false"); @@ -328,38 +320,11 @@ function commonOpenMenuTasks() { } } -function closeSubMenus(item) { - //Close other open submenus - let siblings = []; - let thisSibling = item.parentNode.firstChild; - - while (thisSibling) { - if (thisSibling !== item && thisSibling.nodeType === Node.ELEMENT_NODE) - siblings.push(thisSibling); - thisSibling = thisSibling.nextElementSibling || thisSibling.nextSibling; - } - - for (let i = 0; i < siblings.length; i++) { - if (siblings[i].classList.contains("submenu-open")) { - - setTimeout(function timeoutFunction() { - siblings[i].querySelector(".js-main-nav-hamburger-content").style.height = "0"; - siblings[i].querySelector(".js-main-nav-hamburger-content").classList.add("is-closed"); - siblings[i].querySelector(".js-main-nav-hamburger__container").style.opacity = "0"; - siblings[i].classList.remove("submenu-open"); - siblings[i].querySelector(".js-main-nav-hamburger__top-link").setAttribute("aria-expanded", "false"); - }, 500); - - } - } -} - // Close menu when utility nav is clicked if (null !== utilNavWide) { closeMenu(); } - // Close and reset menu on overlay click if (null !== menuOverlay) { menuOverlay.addEventListener("click", function () {