From bf0647b5659e5014e244f01dc69f33447805a1fd Mon Sep 17 00:00:00 2001 From: Bandana Laishram Date: Fri, 13 Dec 2024 17:33:19 +0530 Subject: [PATCH] Making localnav close on curtain click --- libs/blocks/global-navigation/global-navigation.js | 3 +-- libs/blocks/global-navigation/utilities/utilities.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/libs/blocks/global-navigation/global-navigation.js b/libs/blocks/global-navigation/global-navigation.js index 3577b01d59..5f09197341 100644 --- a/libs/blocks/global-navigation/global-navigation.js +++ b/libs/blocks/global-navigation/global-navigation.js @@ -425,7 +425,7 @@ class Gnav { }); localNav.querySelector('.feds-localnav-curtain').addEventListener('click', (e) => { - trigger({ element: e.currentTarget, event: e }); + trigger({ element: e.currentTarget, event: e, type: 'localNav-curtain' }); }); this.elements.localNav = localNav; localNavItems[0].querySelector('a').textContent = title.trim(); @@ -1046,7 +1046,6 @@ class Gnav { elem?.setAttribute('aria-expanded', false); elem?.addEventListener('click', (e) => { trigger({ element: e.currentTarget, event: e, type: 'headline' }); - setActiveDropdown(e.currentTarget); }); }); } diff --git a/libs/blocks/global-navigation/utilities/utilities.js b/libs/blocks/global-navigation/utilities/utilities.js index 0cfeb92ac1..cb6c90b83c 100644 --- a/libs/blocks/global-navigation/utilities/utilities.js +++ b/libs/blocks/global-navigation/utilities/utilities.js @@ -225,7 +225,7 @@ export function setActiveDropdown(elem, type) { const resetActiveDropdown = () => { [...document.querySelectorAll(selectors.activeDropdown)] .forEach((activeDropdown) => activeDropdown.classList.remove(activeClass)); - if (type && type !== 'localNavItem' && type !== 'headline') { + if (!type || type === 'localNav-curtain') { [...document.querySelectorAll(activeLocalNav)] .forEach((activeDropdown) => activeDropdown.classList.remove('feds-localnav--active')); }