From c991b8f6a0f6b1aa34a60fdc2003907473eb1f26 Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Wed, 17 May 2023 15:28:09 +0900 Subject: [PATCH] UX: Sections not collapsable in "header dropdown" navigation menu (#21604) What is the problem? This is a follow up to 4cca7de22dda2bfa0939c75fb4fe405a93c0a87d. In the commit, CSS was used to disable the collapsing of sections in the header dropdown navigation menu when the `navigation_menu` site setting is set to `header dropdown`. However, using CSS is not the correct approach as the underlying code is still marking the section as collapsable which means that the sections will still be displayed as collapsed with no way to "uncollapse" if the local store has already marked the section as collapsed. What is the fix? This commit removes the usage of CSS to hide the collapsabe button and instead correctly marks the section as not collapsable in the code. --- .../components/sidebar/anonymous/sections.hbs | 2 +- .../sidebar/common/custom-section.hbs | 2 +- .../sidebar/common/custom-sections.hbs | 5 ++- .../components/sidebar/hamburger-dropdown.hbs | 2 +- .../components/sidebar/hamburger-dropdown.js | 13 +++++++ .../app/components/sidebar/user/sections.hbs | 2 +- .../tests/acceptance/sidebar-user-test.js | 36 +++++++++++++++++-- .../stylesheets/desktop/menu-panel.scss | 8 ----- 8 files changed, 55 insertions(+), 15 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/sidebar/anonymous/sections.hbs b/app/assets/javascripts/discourse/app/components/sidebar/anonymous/sections.hbs index a6da74268e6..f757ca0c996 100644 --- a/app/assets/javascripts/discourse/app/components/sidebar/anonymous/sections.hbs +++ b/app/assets/javascripts/discourse/app/components/sidebar/anonymous/sections.hbs @@ -1,5 +1,5 @@ \ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/components/sidebar/hamburger-dropdown.hbs b/app/assets/javascripts/discourse/app/components/sidebar/hamburger-dropdown.hbs index f437f28ec05..3baeb1578bd 100644 --- a/app/assets/javascripts/discourse/app/components/sidebar/hamburger-dropdown.hbs +++ b/app/assets/javascripts/discourse/app/components/sidebar/hamburger-dropdown.hbs @@ -9,7 +9,7 @@ diff --git a/app/assets/javascripts/discourse/app/components/sidebar/hamburger-dropdown.js b/app/assets/javascripts/discourse/app/components/sidebar/hamburger-dropdown.js index a7888ce2d9a..6e17d85693c 100644 --- a/app/assets/javascripts/discourse/app/components/sidebar/hamburger-dropdown.js +++ b/app/assets/javascripts/discourse/app/components/sidebar/hamburger-dropdown.js @@ -5,9 +5,22 @@ import { inject as service } from "@ember/service"; export default class SidebarHamburgerDropdown extends Component { @service appEvents; @service currentUser; + @service site; + @service siteSettings; @action triggerRenderedAppEvent() { this.appEvents.trigger("sidebar-hamburger-dropdown:rendered"); } + + get collapsableSections() { + if ( + this.siteSettings.navigation_menu === "header dropdown" && + !this.args.collapsableSections + ) { + return this.site.mobileView || this.site.narrowDesktopView; + } else { + this.args.collapsableSections; + } + } } diff --git a/app/assets/javascripts/discourse/app/components/sidebar/user/sections.hbs b/app/assets/javascripts/discourse/app/components/sidebar/user/sections.hbs index 3168f543d92..2f7f7f6bf08 100644 --- a/app/assets/javascripts/discourse/app/components/sidebar/user/sections.hbs +++ b/app/assets/javascripts/discourse/app/components/sidebar/user/sections.hbs @@ -1,5 +1,5 @@