Skip to content

Commit

Permalink
Adding active column logic in a large menu (#3276)
Browse files Browse the repository at this point in the history
* Adding active column logic in a large menu

* Apply suggestions from code review

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
bandana147 and github-actions[bot] committed Jan 7, 2025
1 parent fa26fc9 commit 43c3993
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion libs/blocks/global-navigation/global-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,15 @@ 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 43c3993

Please sign in to comment.