Skip to content

Commit

Permalink
Merge pull request #398 from zendesk/revert-376-smansouri.remove-aria…
Browse files Browse the repository at this point in the history
…-expanded-from-section

Revert "Remove aria-expanded attribute from section tag in search result page"
  • Loading branch information
smansouri authored Jul 31, 2023
2 parents e951460 + 5fc6c2f commit 0a2b26e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import { ESCAPE } from "./Keys";

function toggleNavigation(toggle, menu) {
const isExpanded = menu.getAttribute("aria-expanded") === "true";
menu.setAttribute("aria-expanded", !isExpanded);
toggle.setAttribute("aria-expanded", !isExpanded);
}

function closeNavigation(toggle) {
function closeNavigation(toggle, menu) {
menu.setAttribute("aria-expanded", false);
toggle.setAttribute("aria-expanded", false);
toggle.focus();
}
Expand All @@ -24,7 +26,7 @@ window.addEventListener("DOMContentLoaded", () => {
menuList.addEventListener("keyup", (event) => {
if (event.keyCode === ESCAPE) {
event.stopPropagation();
closeNavigation(menuButton);
closeNavigation(menuButton, menuList);
}
});

Expand All @@ -45,7 +47,7 @@ window.addEventListener("DOMContentLoaded", () => {
element.addEventListener("keyup", (event) => {
console.log("escape");
if (event.keyCode === ESCAPE) {
closeNavigation(toggle);
closeNavigation(toggle, element);
}
});
});
Expand Down

0 comments on commit 0a2b26e

Please sign in to comment.