mirror of
https://github.com/discourse/discourse.git
synced 2025-01-21 18:36:14 +08:00
UX: Add auto focus to hamburger and user menu dropdowns (#13165)
This commit is contained in:
parent
8170563693
commit
45dca791b0
|
@ -496,11 +496,21 @@ export default createWidget("header", {
|
||||||
|
|
||||||
this.state.userVisible = !this.state.userVisible;
|
this.state.userVisible = !this.state.userVisible;
|
||||||
this.toggleBodyScrolling(this.state.userVisible);
|
this.toggleBodyScrolling(this.state.userVisible);
|
||||||
|
|
||||||
|
// auto focus on first button in dropdown
|
||||||
|
schedule("afterRender", () =>
|
||||||
|
document.querySelector(".user-menu button")?.focus()
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleHamburger() {
|
toggleHamburger() {
|
||||||
this.state.hamburgerVisible = !this.state.hamburgerVisible;
|
this.state.hamburgerVisible = !this.state.hamburgerVisible;
|
||||||
this.toggleBodyScrolling(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();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleBodyScrolling(bool) {
|
toggleBodyScrolling(bool) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user