mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2026-07-24 14:53:45 -04:00
Fixed odd behavior in navigation tab behavior
This commit is contained in:
@@ -298,6 +298,31 @@ function initialize(config) { // eslint-disable-line func-style
|
||||
})
|
||||
})).listen()
|
||||
|
||||
/* Listener: handle tabbing context for better accessibility */
|
||||
new Material.Event.Listener(document.body, "keydown", ev => {
|
||||
if (ev.keyCode === 9) {
|
||||
const labels = document.querySelectorAll(
|
||||
"[data-md-component=navigation] .md-nav__link[for]:not([tabindex])")
|
||||
Array.prototype.forEach.call(labels, label => {
|
||||
label.tabIndex = 0
|
||||
})
|
||||
}
|
||||
}).listen()
|
||||
|
||||
/* Listener: reset tabbing behavior */
|
||||
new Material.Event.Listener(document.body, "click", () => {
|
||||
const labels = document.querySelectorAll(
|
||||
"[data-md-component=navigation] .md-nav__link[tabindex]")
|
||||
Array.prototype.forEach.call(labels, label => {
|
||||
label.removeAttribute("tabIndex")
|
||||
})
|
||||
}).listen()
|
||||
|
||||
document.body.addEventListener("click", () => {
|
||||
if (document.body.dataset.mdState === "tabbing")
|
||||
document.body.dataset.mdState = ""
|
||||
})
|
||||
|
||||
/* Listener: close drawer when anchor links are clicked */
|
||||
new Material.Event.MatchMedia("(max-width: 959px)",
|
||||
new Material.Event.Listener("[data-md-component=navigation] [href^='#']",
|
||||
|
||||
Reference in New Issue
Block a user