mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2026-08-04 19:45:08 -04:00
Improved accessibility of sidebar navigation
This commit is contained in:
@@ -43,6 +43,8 @@ import {
|
||||
import { configuration, feature } from "./_"
|
||||
import {
|
||||
at,
|
||||
getActiveElement,
|
||||
getElement,
|
||||
getOptionalElement,
|
||||
requestJSON,
|
||||
setLocation,
|
||||
@@ -186,6 +188,18 @@ keyboard$
|
||||
if (typeof next !== "undefined")
|
||||
setLocation(next)
|
||||
break
|
||||
|
||||
/* Expand navigation, see https://bit.ly/3ZjG5io */
|
||||
case "Enter":
|
||||
const active = getActiveElement()
|
||||
if (active instanceof HTMLLabelElement) {
|
||||
const id = `[id="${active.htmlFor}"]`
|
||||
const input = getElement<HTMLInputElement>(id)
|
||||
active.setAttribute(
|
||||
"aria-expanded",
|
||||
`${input.checked = !input.checked}`
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user