Skip to content

A platform for community discussion. Free, open, simple.

FIX: Override navigation menu to "legacy" via query param not working (#20402)

Alan Guo Xiang Tanc11fd4fdf928
diff --git a/app/assets/javascripts/discourse/app/widgets/header.js b/app/assets/javascripts/discourse/app/widgets/header.js
index 12a47387490..61305a68b8e 100644
--- a/app/assets/javascripts/discourse/app/widgets/header.js
+++ b/app/assets/javascripts/discourse/app/widgets/header.js
@@ -511,7 +511,8 @@ export default createWidget("header", {
} else if (state.hamburgerVisible) {
if (
attrs.navigationMenuQueryParamOverride === "header_dropdown" ||
- (this.siteSettings.navigation_menu !== "legacy" &&
+ (attrs.navigationMenuQueryParamOverride !== "legacy" &&
+ this.siteSettings.navigation_menu !== "legacy" &&
(!attrs.sidebarEnabled || this.site.narrowDesktopView))
) {
panels.push(this.attach("revamped-hamburger-menu-wrapper", {}));
diff --git a/spec/system/page_objects/components/legacy_header_dropdown.rb b/spec/system/page_objects/components/legacy_header_dropdown.rb
index f04fd68ce2f..8273e16940e 100644
--- a/spec/system/page_objects/components/legacy_header_dropdown.rb
+++ b/spec/system/page_objects/components/legacy_header_dropdown.rb
@@ -8,7 +8,7 @@ module PageObjects
end
def visible?
- page.has_css?(".menu-panel.drop-down")
+ page.has_css?(".menu-container-general-links")
end
end
end
diff --git a/spec/system/page_objects/components/sidebar_header_dropdown.rb b/spec/system/page_objects/components/sidebar_header_dropdown.rb
index fa86f1c72f3..8087952e9da 100644
--- a/spec/system/page_objects/components/sidebar_header_dropdown.rb
+++ b/spec/system/page_objects/components/sidebar_header_dropdown.rb
@@ -8,7 +8,7 @@ module PageObjects
end
def visible?
- page.has_css?(".revamped.menu-panel.drop-down")
+ page.has_css?(".sidebar-hamburger-dropdown")
end
end
end
diff --git a/spec/system/viewing_sidebar_spec.rb b/spec/system/viewing_sidebar_spec.rb
index 48b0faf4485..e830fe59440 100644
--- a/spec/system/viewing_sidebar_spec.rb
+++ b/spec/system/viewing_sidebar_spec.rb
@@ -34,6 +34,32 @@ describe "Viewing sidebar", type: :system, js: true do
end
end
+ describe "when using the header dropdown navigation menu" do
+ before { SiteSetting.navigation_menu = "header dropdown" }
+
+ it "should display the sidebar when `navigation_menu` query param is 'sidebar'" do
+ visit("/latest?navigation_menu=sidebar")
+
+ sidebar = PageObjects::Components::Sidebar.new
+
+ expect(sidebar).to be_visible
+ expect(page).not_to have_css(".hamburger-dropdown")
+ end
+
+ it "should display the legacy dropdown menu when `navigation_menu` query param is 'legacy'" do
+ visit("/latest?navigation_menu=legacy")
+
+ sidebar = PageObjects::Components::Sidebar.new
+
+ expect(sidebar).to be_not_visible
+
+ legacy_header_dropdown = PageObjects::Components::LegacyHeaderDropdown.new
+ legacy_header_dropdown.click
+
+ expect(legacy_header_dropdown).to be_visible
+ end
+ end
+
describe "when using the sidebar navigation menu" do
before { SiteSetting.navigation_menu = "sidebar" }