From 7abbccf2a36a18d7e83773919781358082b6427f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Wed, 5 Feb 2025 17:50:57 +0100 Subject: [PATCH] Store the tools panel size --- src/canvas/DesktopElement.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/canvas/DesktopElement.ts b/src/canvas/DesktopElement.ts index ecb07d586f79..f689a27703b8 100644 --- a/src/canvas/DesktopElement.ts +++ b/src/canvas/DesktopElement.ts @@ -100,6 +100,8 @@ export default class GmfDesktopCanvas extends BaseElement { private minDatapanelWidth_ = 320; // Minimum tool panel width in px private minToolpanelWidth_ = 280; + // Store the tools panel size + private toolsPanelWidth_: {[id: string]: string} = {}; static styles = [ ...BaseElement.styles, @@ -405,11 +407,18 @@ export default class GmfDesktopCanvas extends BaseElement { panels.getActiveToolPanel().subscribe({ next: (panel: string) => { const styles = getComputedStyle(document.documentElement); - let width = styles.getPropertyValue(`--right-panel-width-${panel}`); + // Get the current width of the selected tool panel + let width = this.toolsPanelWidth_[panel]; if (!width) { + // Get the default value for the selected tool panel + width = styles.getPropertyValue(`--right-panel-width-${panel}`); + } + if (!width) { + // Get the default value for all tool panel width = styles.getPropertyValue(`--right-panel-width`); } if (!width) { + // Use an hardcoded default value width = '17.5rem'; } document.documentElement.style.setProperty('--current-right-panel-width', width); @@ -592,6 +601,7 @@ export default class GmfDesktopCanvas extends BaseElement { panelResizeEvent.separator.style.left = `${panelResizeEvent.offsetLeft + deltaX}px`; const newRightWidth = `${panelResizeEvent.rightWidth - deltaX}px`; document.documentElement.style.setProperty(`--current-right-panel-width`, newRightWidth); + this.toolsPanelWidth_[this.toolPanel_] = newRightWidth; } return event;