From d71a82786a0ac4a87800c689bdb65ee9c2905f79 Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Mon, 20 Feb 2023 11:34:37 +0800 Subject: [PATCH] UX: Hide hamburger dropdown when `enable_sidebar` query param is used (#20367) --- .../javascripts/discourse/app/widgets/header.js | 6 +----- spec/system/page_objects/components/sidebar.rb | 4 ++++ spec/system/viewing_sidebar_spec.rb | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/discourse/app/widgets/header.js b/app/assets/javascripts/discourse/app/widgets/header.js index 2a4fb0ef5c4..50be1ea06a7 100644 --- a/app/assets/javascripts/discourse/app/widgets/header.js +++ b/app/assets/javascripts/discourse/app/widgets/header.js @@ -339,11 +339,7 @@ createWidget("header-icons", { }, }); - if ( - this.siteSettings.navigation_menu === "legacy" || - !attrs.sidebarEnabled || - this.site.mobileView - ) { + if (!attrs.sidebarEnabled || this.site.mobileView) { icons.push(hamburger); } diff --git a/spec/system/page_objects/components/sidebar.rb b/spec/system/page_objects/components/sidebar.rb index b01bb3a1ba3..3ddb24cb545 100644 --- a/spec/system/page_objects/components/sidebar.rb +++ b/spec/system/page_objects/components/sidebar.rb @@ -7,6 +7,10 @@ module PageObjects page.has_css?("#d-sidebar") end + def not_visible? + page.has_no_css?("#d-sidebar") + end + def has_category_section_link?(category) page.has_link?(category.name, class: "sidebar-section-link") end diff --git a/spec/system/viewing_sidebar_spec.rb b/spec/system/viewing_sidebar_spec.rb index 4b9da86e9c4..5dfe75f87a3 100644 --- a/spec/system/viewing_sidebar_spec.rb +++ b/spec/system/viewing_sidebar_spec.rb @@ -17,6 +17,22 @@ describe "Viewing sidebar", type: :system, js: true do expect(sidebar).to be_visible expect(sidebar).to have_category_section_link(category_sidebar_section_link.linkable) + expect(page).not_to have_css(".hamburger-dropdown") + end + end + + describe "when using the sidebar navigation menu" do + before { SiteSetting.navigation_menu = "sidebar" } + + it "should not display the sidebar when `enable_sidebar` query param is '0'" do + sign_in(user) + + visit("/latest?enable_sidebar=0") + + sidebar = PageObjects::Components::Sidebar.new + + expect(sidebar).to be_not_visible + expect(page).to have_css(".hamburger-dropdown") end end end