From bce56d843cbaec8255193555f72e24ded4b76ab3 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Tue, 23 May 2023 18:29:12 +0200 Subject: [PATCH] FIX: keeps panel size when changing content (#21698) Before this commit the following actions would have shown the issue: - visit a thread - changes the width of the side panel - open threads list - the size has reverted to previous state This was caused by the width change to not correctly be tracked. --- .../discourse/components/chat-side-panel.hbs | 2 +- .../discourse/components/chat-side-panel.js | 15 ++------------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-side-panel.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-side-panel.hbs index 014ee2be0e2..f2edb56d59a 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat-side-panel.hbs +++ b/plugins/chat/assets/javascripts/discourse/components/chat-side-panel.hbs @@ -9,7 +9,7 @@ }} style={{if (and this.site.desktopView this.chatStateManager.isFullPageActive) - this.width + this.widthStyle }} > {{yield}} diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-side-panel.js b/plugins/chat/assets/javascripts/discourse/components/chat-side-panel.js index b6916fa2336..8c54bf6d798 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat-side-panel.js +++ b/plugins/chat/assets/javascripts/discourse/components/chat-side-panel.js @@ -12,25 +12,13 @@ export default class ChatSidePanel extends Component { @service site; @tracked sidePanel; + @tracked widthStyle; @action setSidePanel(element) { this.sidePanel = element; } - get width() { - if (!this.sidePanel) { - return; - } - - const maxWidth = Math.min( - this.#maxWidth(this.sidePanel), - this.chatSidePanelSize.width - ); - - return htmlSafe(`width:${maxWidth}px`); - } - @action didResize(element, size) { if (this.isDestroying || this.isDestroyed) { @@ -43,6 +31,7 @@ export default class ChatSidePanel extends Component { if (mainPanelWidth > MIN_CHAT_CHANNEL_WIDTH) { this.chatSidePanelSize.width = size.width; element.style.width = size.width + "px"; + this.widthStyle = htmlSafe(`width:${size.width}px`); } }