Skip to content

Commit

Permalink
Fix JS, navigation expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkrzyskow committed Feb 4, 2024
1 parent b917f03 commit 15e8a2d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions overrides/assets/javascripts/extra.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,19 @@ function gmcExpandNavigation() {
return;
}

const activeLink = document.querySelector(".md-nav__link--active");
const activeLinkLabel = document.querySelector("label.md-nav__link--active");

if (!activeLink) {
if (!activeLinkLabel) {
return;
}

let activeNav = activeLink.parentElement.querySelector("nav");
const navID = activeLinkLabel.id;

let activeNav = document.querySelector(`nav[aria-labelledby="${navID}"]`);

if (!activeNav || activeNav.className.includes("md-nav--secondary")) {
// gmcDebug(`nav not foundInParent`);
activeNav = activeLink.closest("nav");
// gmcDebug(`nav with id ${navID} not found`);
activeNav = activeLinkLabel.closest("nav");
}

if (activeNav.dataset.hasOwnProperty("mdLevel")) {
Expand Down

0 comments on commit 15e8a2d

Please sign in to comment.