Skip to content

Commit 1afdb5d

Browse files
authored
UX: always close hamburger menu when navigating to admin (#32651)
When we create a custom homepage using the `custom_homepage` modifier we can hide the sidebar using `{{hideApplicationSidebar}}` in the template — this forces the hamburger dropdown to appear in the header. This creates an issue when navigating from the custom homepage to the admin area, because when the route transitions the hamburger menu isn't closed... and at this point, it cannot be closed at all. The `clickOutside` listener from the open menu is calling `toggleNavigation`, which is now the sidebar... so instead of closing the hamburger menu, it toggles the sidebar and prevents other elements from being clicked (because the `clickOuside` listener is only removed when the hamburger menu is destroyed). ![image](https://github.com/user-attachments/assets/b6893513-6f0e-4f5b-8d47-6b63916c0a29) This change ensures that when the admin sidebar is forced, the hamburger menu will be hidden.
1 parent 6154fa6 commit 1afdb5d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

app/assets/javascripts/admin/addon/services/admin-sidebar-state-manager.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import AdminSearchModal from "admin/components/modal/admin-search";
55

66
export default class AdminSidebarStateManager extends Service {
77
@service sidebarState;
8+
@service header;
89

910
STORE_NAMESPACE = "discourse_admin_sidebar_experiment_";
1011
keywords = {};
@@ -67,6 +68,11 @@ export default class AdminSidebarStateManager extends Service {
6768
this.sidebarState.setSeparatedMode();
6869
this.sidebarState.hideSwitchPanelButtons();
6970
this.sidebarState.isForcingSidebar = true;
71+
72+
// we may navigate to admin from the header dropdown
73+
// and when we do, we have to close it
74+
this.header.hamburgerVisible = false;
75+
7076
return true;
7177
}
7278
}

0 commit comments

Comments
 (0)