From bbd67eff08b84bdc0db6f8b4ba0569e3c07c2fc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Saquetim?= <1108771+megothss@users.noreply.github.com> Date: Tue, 9 Jul 2024 18:32:29 -0300 Subject: [PATCH] DEV: Improve the sidebar section expansion handling (#27805) Handles the cases where the sections titles are Unicode only strings, allowing them to be expanded separately if the Unicode string contains letters. Also prevents a sidebar section with the header hidden to be displayed collapsed. --- .../sidebar/anonymous/custom-sections.gjs | 4 +-- .../sidebar/common/custom-sections.gjs | 2 +- .../app/components/sidebar/section.gjs | 13 +++++-- .../sidebar/user/custom-sections.gjs | 4 +-- .../discourse/app/lib/sidebar/section.js | 6 +++- .../discourse/app/lib/utilities.js | 18 ++++++++++ .../tests/unit/lib/utilities-test.js | 32 +++++++++++++++++ spec/system/custom_sidebar_sections_spec.rb | 35 +++++++++++++++++++ .../components/navigation_menu/base.rb | 18 +++++++++- 9 files changed, 123 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/sidebar/anonymous/custom-sections.gjs b/app/assets/javascripts/discourse/app/components/sidebar/anonymous/custom-sections.gjs index 0b540f9290a..398380c574f 100644 --- a/app/assets/javascripts/discourse/app/components/sidebar/anonymous/custom-sections.gjs +++ b/app/assets/javascripts/discourse/app/components/sidebar/anonymous/custom-sections.gjs @@ -1,5 +1,5 @@ -import SidebarCustomSection from "../common/custom-sections"; +import SidebarCustomSections from "../common/custom-sections"; -export default class SidebarAnonymousCustomSections extends SidebarCustomSection { +export default class SidebarAnonymousCustomSections extends SidebarCustomSections { anonymous = true; } diff --git a/app/assets/javascripts/discourse/app/components/sidebar/common/custom-sections.gjs b/app/assets/javascripts/discourse/app/components/sidebar/common/custom-sections.gjs index fdbd653e411..a4e50ab5ca6 100644 --- a/app/assets/javascripts/discourse/app/components/sidebar/common/custom-sections.gjs +++ b/app/assets/javascripts/discourse/app/components/sidebar/common/custom-sections.gjs @@ -2,7 +2,7 @@ import Component from "@glimmer/component"; import { service } from "@ember/service"; import CustomSection from "./custom-section"; -export default class SidebarCustomSection extends Component { +export default class SidebarCustomSections extends Component { @service currentUser; @service router; @service messageBus; diff --git a/app/assets/javascripts/discourse/app/components/sidebar/section.gjs b/app/assets/javascripts/discourse/app/components/sidebar/section.gjs index f5bf177de08..d565b27a247 100644 --- a/app/assets/javascripts/discourse/app/components/sidebar/section.gjs +++ b/app/assets/javascripts/discourse/app/components/sidebar/section.gjs @@ -5,6 +5,7 @@ import { action } from "@ember/object"; import didInsert from "@ember/render-modifiers/modifiers/did-insert"; import { service } from "@ember/service"; import { isEmpty } from "@ember/utils"; +import concatClass from "discourse/helpers/concat-class"; import { getCollapsedSidebarSectionKey, getSidebarSectionContentId, @@ -60,7 +61,7 @@ export default class SidebarSection extends Component { } get displaySectionContent() { - if (!isEmpty(this.sidebarState.filter)) { + if (this.args.hideSectionHeader || !isEmpty(this.sidebarState.filter)) { return true; } @@ -115,7 +116,15 @@ export default class SidebarSection extends Component {