UX: Remove focus on hamburger icon after toggle (#18101)

This commit is contained in:
Alan Guo Xiang Tan 2022-08-29 10:27:24 +08:00 committed by GitHub
parent 6294659022
commit d80535d78f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -596,9 +596,14 @@ export default createWidget("header", {
this.state.hamburgerVisible = !this.state.hamburgerVisible;
this.toggleBodyScrolling(this.state.hamburgerVisible);
// auto focus on first link in dropdown
schedule("afterRender", () => {
document.querySelector(".hamburger-panel .menu-links a")?.focus();
if (this.siteSettings.enable_experimental_sidebar_hamburger) {
// Remove focus from hamburger toggle button
document.querySelector("#toggle-hamburger-menu").blur();
} else {
// auto focus on first link in dropdown
document.querySelector(".hamburger-panel .menu-links a")?.focus();
}
});
}
},