diff --git a/src/navigation.js b/src/navigation.js index 16cfe5658..ecbfab0c7 100644 --- a/src/navigation.js +++ b/src/navigation.js @@ -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(); } @@ -24,7 +26,7 @@ window.addEventListener("DOMContentLoaded", () => { menuList.addEventListener("keyup", (event) => { if (event.keyCode === ESCAPE) { event.stopPropagation(); - closeNavigation(menuButton); + closeNavigation(menuButton, menuList); } }); @@ -45,7 +47,7 @@ window.addEventListener("DOMContentLoaded", () => { element.addEventListener("keyup", (event) => { console.log("escape"); if (event.keyCode === ESCAPE) { - closeNavigation(toggle); + closeNavigation(toggle, element); } }); });