Skip to content

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

UX: Sections not collapsable in "header dropdown" navigation menu (#21604)

Alan Guo Xiang Tanc991b8f6a0f6
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 @@
<div class="sidebar-sections sidebar-sections-anonymous">
- <Sidebar::Anonymous::CustomSections />
+ <Sidebar::Anonymous::CustomSections @collapsable={{@collapsableSections}} />
<Sidebar::Anonymous::CategoriesSection
@collapsable={{@collapsableSections}}
/>
diff --git a/app/assets/javascripts/discourse/app/components/sidebar/common/custom-section.hbs b/app/assets/javascripts/discourse/app/components/sidebar/common/custom-section.hbs
index 00363aa5e09..bf4da6d19dd 100644
--- a/app/assets/javascripts/discourse/app/components/sidebar/common/custom-section.hbs
+++ b/app/assets/javascripts/discourse/app/components/sidebar/common/custom-section.hbs
@@ -1,7 +1,7 @@
<Sidebar::Section
@sectionName={{this.section.slug}}
@headerLinkText={{this.section.decoratedTitle}}
- @collapsable={{true}}
+ @collapsable={{@collapsable}}
@headerActions={{this.section.headerActions}}
@headerActionsIcon={{this.section.headerActionIcon}}
@class={{this.section.dragCss}}
diff --git a/app/assets/javascripts/discourse/app/components/sidebar/common/custom-sections.hbs b/app/assets/javascripts/discourse/app/components/sidebar/common/custom-sections.hbs
index 154a0c5dc89..c07cd0ea437 100644
--- a/app/assets/javascripts/discourse/app/components/sidebar/common/custom-sections.hbs
+++ b/app/assets/javascripts/discourse/app/components/sidebar/common/custom-sections.hbs
@@ -1,5 +1,8 @@
<div class="sidebar-custom-sections">
{{#each this.sections as |section|}}
- <Sidebar::Common::CustomSection @sectionData={{section}} />
+ <Sidebar::Common::CustomSection
+ @sectionData={{section}}
+ @collapsable={{@collapsable}}
+ />
{{/each}}
</div>
\ 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 @@
<div class="sidebar-hamburger-dropdown">
<Sidebar::Sections
@currentUser={{this.currentUser}}
- @collapsableSections={{true}}
+ @collapsableSections={{this.collapsableSections}}
/>
<Sidebar::Footer @tagName="" />
</div>
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 @@
<div class="sidebar-sections">
- <Sidebar::User::CustomSections />
+ <Sidebar::User::CustomSections @collapsable={{@collapsableSections}} />
<Sidebar::User::CategoriesSection @collapsable={{@collapsableSections}} />
{{#if this.currentUser.display_sidebar_tags}}
diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-test.js
index fbbc58aa5cb..d5899b87d21 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-test.js
@@ -9,7 +9,7 @@ import {
} from "discourse/tests/helpers/qunit-helpers";
acceptance(
- "Sidebar - Logged on user - Experimental sidebar and hamburger setting disabled",
+ "Sidebar - Logged on user - Legacy navigation menu enabled",
function (needs) {
needs.user();
@@ -27,7 +27,29 @@ acceptance(
);
acceptance(
- "Sidebar - Logged on user - header dropdown navigation menu enabled",
+ "Sidebar - Logged on user - Mobile view - Header dropdown navigation menu enabled",
+ function (needs) {
+ needs.user();
+ needs.mobileView();
+
+ needs.settings({
+ navigation_menu: "header dropdown",
+ });
+
+ test("sections are collapsable", async function (assert) {
+ await visit("/");
+ await click(".hamburger-dropdown");
+
+ assert.ok(
+ exists(".sidebar-section-header.sidebar-section-header-collapsable"),
+ "sections are collapsable"
+ );
+ });
+ }
+);
+
+acceptance(
+ "Sidebar - Logged on user - Desktop view - Header dropdown navigation menu enabled",
function (needs) {
needs.user();
@@ -52,6 +74,16 @@ acceptance(
);
});
+ test("sections are not collapsable", async function (assert) {
+ await visit("/");
+ await click(".hamburger-dropdown");
+
+ assert.notOk(
+ exists(".sidebar-section-header.sidebar-section-header-collapsable"),
+ "sections are not collapsable"
+ );
+ });
+
test("'more' dropdown should display as regular list items in header dropdown mode", async function (assert) {
await visit("/");
await click(".hamburger-dropdown");
diff --git a/app/assets/stylesheets/desktop/menu-panel.scss b/app/assets/stylesheets/desktop/menu-panel.scss
index 6ed8c50c2d6..7c2b73c38a7 100644
--- a/app/assets/stylesheets/desktop/menu-panel.scss
+++ b/app/assets/stylesheets/desktop/menu-panel.scss
@@ -54,14 +54,6 @@
}
}
- .sidebar-section-wrapper .sidebar-section-header-caret {
- display: none;
- }
-
- .sidebar-section-header-collapsable {
- pointer-events: none; // disabling collapsible sections
- }
-
.sidebar-custom-sections .d-icon-globe {
left: -0.9em;
top: 0.35em;