diff --git a/app/assets/javascripts/discourse/app/components/header.gjs b/app/assets/javascripts/discourse/app/components/header.gjs index 0b459b57074..54b33121332 100644 --- a/app/assets/javascripts/discourse/app/components/header.gjs +++ b/app/assets/javascripts/discourse/app/components/header.gjs @@ -40,6 +40,7 @@ export default class GlimmerHeader extends Component { @service router; @service search; @service currentUser; + @service siteSettings; @service site; @service appEvents; @service header; @@ -71,7 +72,7 @@ export default class GlimmerHeader extends Component { this.toggleUserMenu(); break; case "hamburger": - this.toggleHamburger(); + this.toggleNavigationMenu(); break; case "page-search": if (!this.togglePageSearch()) { @@ -148,15 +149,33 @@ export default class GlimmerHeader extends Component { } @action - toggleHamburger() { - if (this.args.sidebarEnabled && !this.site.narrowDesktopView) { - this.args.toggleSidebar(); - this.args.animateMenu(); - } else { - this.header.hamburgerVisible = !this.header.hamburgerVisible; - this.toggleBodyScrolling(this.header.hamburgerVisible); - this.args.animateMenu(); + toggleNavigationMenu(override = null) { + if (override === "sidebar") { + return this.toggleSidebar(); } + + if (override === "hamburger") { + return this.toggleHamburger(); + } + + if (this.args.sidebarEnabled && !this.site.narrowDesktopView) { + this.toggleSidebar(); + } else { + this.toggleHamburger(); + } + } + + @action + toggleHamburger() { + this.header.hamburgerVisible = !this.header.hamburgerVisible; + this.toggleBodyScrolling(this.header.hamburgerVisible); + this.args.animateMenu(); + } + + @action + toggleSidebar() { + this.args.toggleSidebar(); + this.args.animateMenu(); } @action @@ -171,7 +190,7 @@ export default class GlimmerHeader extends Component {