diff options
author | 2024-02-14 17:07:56 +0800 | |
---|---|---|
committer | 2024-02-14 20:11:23 -0800 | |
commit | 5c97771e61d0814cc85f2169db72768920532653 (patch) | |
tree | 89ab91cc891fb1274bc803bfeb4d041acbc6b567 /internal/ui/static/js/app.js | |
parent | c9cbe8afd51c402ec5afed53f58ee68d7df3cf1c (diff) | |
download | v2-5c97771e61d0814cc85f2169db72768920532653.tar.gz v2-5c97771e61d0814cc85f2169db72768920532653.tar.zst v2-5c97771e61d0814cc85f2169db72768920532653.zip |
fix macOS VoiceOver didn't announce details and summary expand
Diffstat (limited to 'internal/ui/static/js/app.js')
-rw-r--r-- | internal/ui/static/js/app.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/internal/ui/static/js/app.js b/internal/ui/static/js/app.js index 61872ed1..99145d49 100644 --- a/internal/ui/static/js/app.js +++ b/internal/ui/static/js/app.js @@ -54,6 +54,27 @@ function checkMenuToggleModeByLayout() { } } +function fixVoiceOverDetailsSummaryBug() { + const detailsElements = document.querySelectorAll("details") + detailsElements.forEach((details) => { + const summaryElement = details.querySelector("summary") + summaryElement.setAttribute("role", "button") + setSummaryAriaExpandedByDetails(details, summaryElement) + + details.addEventListener("toggle", () => { + setSummaryAriaExpandedByDetails(details, summaryElement) + }) + }) + + function setSummaryAriaExpandedByDetails(details, summary) { + if (details.open) { + summary.setAttribute("aria-expanded", "true") + } else { + summary.setAttribute("aria-expanded", "false") + } + } +} + // Show and hide the main menu on mobile devices. function toggleMainMenu(event) { if (event.type === "keydown" && !(event.key === "Enter" || event.key === " ")) { |