FIX: We can't use `?.` yet (#13168)

This commit is contained in:
Robin Ward 2021-05-26 17:30:27 -04:00 committed by GitHub
parent d45682716b
commit 96fd202d9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 4 deletions

View File

@ -508,9 +508,12 @@ export default createWidget("header", {
this.toggleBodyScrolling(this.state.userVisible);
// auto focus on first button in dropdown
schedule("afterRender", () =>
document.querySelector(".user-menu button")?.focus()
);
schedule("afterRender", () => {
let elem = document.querySelector(".user-menu button");
if (elem) {
elem.focus();
}
});
},
toggleHamburger() {
@ -519,7 +522,10 @@ export default createWidget("header", {
// auto focus on first link in dropdown
schedule("afterRender", () => {
document.querySelector(".hamburger-panel .menu-links a")?.focus();
let elem = document.querySelector(".hamburger-panel .menu-links a");
if (elem) {
elem.focus();
}
});
},