Skip to content

Commit

Permalink
Adding active column logic in a large menu
Browse files Browse the repository at this point in the history
  • Loading branch information
bandana147 committed Nov 28, 2024
1 parent 7dc81da commit 5c1b262
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion libs/blocks/global-navigation/global-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,16 @@ class Gnav {

const makeTabActive = (popup) => {
if (!popup?.querySelector('.tabs [aria-selected="true"]')) {
setTimeout(() => popup?.querySelector('.tab')?.click(), 100);
const { origin, pathname } = window.location;
const url = `${origin}${pathname}`;
setTimeout(() => {
const activeLink = [
...popup.querySelectorAll('a:not([data-modal-hash])'),
].find((el)=> (el.href === url || el.href.startsWith(`${url}?`) || el.href.startsWith(`${url}#`)));

const tabIndex = activeLink ? +activeLink.parentNode.id : 0;
popup.querySelectorAll('.tab')[tabIndex]?.click();
}, 100);
}
};

Expand Down

0 comments on commit 5c1b262

Please sign in to comment.