Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport master] Store the tools panel size #9611

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/canvas/DesktopElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
Loading