diff --git a/static/script.js b/static/script.js index aebc9225..905e7119 100644 --- a/static/script.js +++ b/static/script.js @@ -31,6 +31,8 @@ var isDetailPage = typeof PROJECT_ID !== "undefined"; // classList.toggle returns true if class was added, false if removed var isOpen = menu.classList.toggle("open"); toggle.classList.toggle("open", isOpen); + // Keep aria-expanded in sync so screen readers announce state changes + toggle.setAttribute("aria-expanded", String(isOpen)); // Keep aria-expanded in sync so screen readers know if menu is open or closed toggle.setAttribute("aria-expanded", isOpen); }); @@ -40,8 +42,19 @@ var isDetailPage = typeof PROJECT_ID !== "undefined"; link.addEventListener("click", function () { menu.classList.remove("open"); toggle.classList.remove("open"); + toggle.setAttribute("aria-expanded", "false"); }); }); + + // Also close the menu when Escape is pressed + document.addEventListener("keydown", function (evt) { + if (evt.key === "Escape" && menu.classList.contains("open")) { + menu.classList.remove("open"); + toggle.classList.remove("open"); + toggle.setAttribute("aria-expanded", "false"); + toggle.focus(); + } + }); })(); @@ -245,6 +258,7 @@ if (isIndexPage) { } }); + // Add skill on quick-pick chip click; also support Space/Enter for keyboard users // Add/toggle skill on quick-pick chip click quickPickChips.forEach(function (chip) { chip.addEventListener("click", function () { @@ -290,6 +304,23 @@ if (isIndexPage) { }); } + // Add skill on quick-pick chip click + quickPickChips.forEach(function (chip) { + chip.addEventListener("click", function () { + addSkill(chip.getAttribute("data-skill")); + hideSuggestions(); + skillsTextInput.value = ""; + }); + // Keyboard users expect buttons to respond to Enter and Space by default + // (they already do because these are -