Skip to content

Commit

Permalink
Merge pull request GSA#7979 from GSA/nl-patch-guide-sidenav-a11y
Browse files Browse the repository at this point in the history
Fix container element #3
  • Loading branch information
RileySeaburg authored Oct 1, 2024
2 parents 091382a + 071ad89 commit 437fde0
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions themes/digital.gov/src/js/guide-sidenav.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,18 @@ function createSublist() {
const subList = document.createElement("ul");
subList.classList.add("usa-sidenav__sublist");
const links = createLinks();
links.forEach((link) => {
const subItem = document.createElement("li");
subItem.classList.add("usa-sidenav__item");
subItem.appendChild(link);
subList.appendChild(subItem);
});
const currentItem = document.querySelector(".usa-sidenav__item.current");
if (currentItem) {
currentItem.appendChild(subList);
// check if links has items to avoid displaying an empty ul
if (links.length !== 0) {
links.forEach((link) => {
const subItem = document.createElement("li");
subItem.classList.add("usa-sidenav__item");
subItem.appendChild(link);
subList.appendChild(subItem);
});
const currentItem = document.querySelector(".usa-sidenav__item.current");
if (currentItem) {
currentItem.appendChild(subList);
}
}
}

Expand Down

0 comments on commit 437fde0

Please sign in to comment.