From d80535d78f92cb6d3f1d0aaed1863bcfb6004bd5 Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Mon, 29 Aug 2022 10:27:24 +0800 Subject: [PATCH] UX: Remove focus on hamburger icon after toggle (#18101) --- app/assets/javascripts/discourse/app/widgets/header.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/app/widgets/header.js b/app/assets/javascripts/discourse/app/widgets/header.js index 56ebb4238b0..5a160aab453 100644 --- a/app/assets/javascripts/discourse/app/widgets/header.js +++ b/app/assets/javascripts/discourse/app/widgets/header.js @@ -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(); + } }); } },