From 7230b0d43644c2a0170b3f3ddeeb810b08a1c9d1 Mon Sep 17 00:00:00 2001 From: Krzysztof Kotlarek Date: Mon, 18 Jul 2022 15:46:49 +1000 Subject: [PATCH] FIX: pass custom section willDestroy (#17551) Custom sections `willDestroy` function has to be passed to SidebarSection component to call when component is removed. --- .../javascripts/discourse/app/components/sidebar/section.js | 6 ++++++ .../discourse/app/templates/components/sidebar.hbs | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/app/components/sidebar/section.js b/app/assets/javascripts/discourse/app/components/sidebar/section.js index 41c6c36b925..79eda4f28aa 100644 --- a/app/assets/javascripts/discourse/app/components/sidebar/section.js +++ b/app/assets/javascripts/discourse/app/components/sidebar/section.js @@ -16,6 +16,12 @@ export default class SidebarSection extends GlimmerComponent { : false; } + willDestroy() { + if (this.args.willDestroy) { + this.args.willDestroy(); + } + } + @action toggleSectionDisplay() { this.displaySection = !this.displaySection; diff --git a/app/assets/javascripts/discourse/app/templates/components/sidebar.hbs b/app/assets/javascripts/discourse/app/templates/components/sidebar.hbs index ad291073bd7..12058f9218c 100644 --- a/app/assets/javascripts/discourse/app/templates/components/sidebar.hbs +++ b/app/assets/javascripts/discourse/app/templates/components/sidebar.hbs @@ -18,7 +18,8 @@ @headerLinkText={{customSection.text}} @headerLinkTitle={{customSection.title}} @headerActionsIcon={{customSection.actionsIcon}} - @headerActions={{customSection.actions}}> + @headerActions={{customSection.actions}} + @willDestroy={{customSection.willDestroy}}> {{#each customSection.links as |link|}}