1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-26 18:21:01 +00:00

fix macOS VoiceOver didn't announce details and summary expand

This commit is contained in:
krvpb024 2024-02-14 17:07:56 +08:00 committed by Frédéric Guillot
parent c9cbe8afd5
commit 5c97771e61
4 changed files with 35 additions and 10 deletions

View file

@ -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 === " ")) {