From 151d808a9fead8f261e6351e60fd6d10200c0665 Mon Sep 17 00:00:00 2001 From: Matas Date: Fri, 2 Aug 2024 11:01:12 -0400 Subject: [PATCH] misc(docs): handle case where sideMenu is already expanded on page load (#1135) --- docs/dokka-presets/scripts/accessibility.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/dokka-presets/scripts/accessibility.js b/docs/dokka-presets/scripts/accessibility.js index bbb1994fa..c27d4531e 100644 --- a/docs/dokka-presets/scripts/accessibility.js +++ b/docs/dokka-presets/scripts/accessibility.js @@ -83,7 +83,10 @@ function ensureNavButtonInteractable() { // Make the navButton focusable, add accessibility information navButton.setAttribute('tabindex', '0'); navButton.setAttribute('role', 'button'); - navButton.setAttribute('aria-expanded', 'false'); + + const sideMenuPartParent = navButton.closest(".sideMenuPart") + const navButtonExpanded = sideMenuPartParent ? (sideMenuPartParent.classList.contains('hidden') ? 'false' : 'true') : 'false' + navButton.setAttribute('aria-expanded', navButtonExpanded); // Grab the page ID, use it for aria-label and aria-controls const sectionName = navButton.parentElement.parentElement.getAttribute('pageid')