From 728807f40137f2abfbc8863657e890cf40bb2ed2 Mon Sep 17 00:00:00 2001 From: Hao Kang <89672451+haok1402@users.noreply.github.com> Date: Mon, 11 Dec 2023 05:11:32 -0500 Subject: [PATCH] Fix toggle functionality for widgets. (#7178) Co-authored-by: cccindyyyl Co-authored-by: Bojun Li Co-authored-by: Sen Feng Co-authored-by: Ariel Kwak Co-authored-by: Jeremy Tuloup --- packages/application/src/panelhandler.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/application/src/panelhandler.ts b/packages/application/src/panelhandler.ts index 6973d99e0..525b62bb0 100644 --- a/packages/application/src/panelhandler.ts +++ b/packages/application/src/panelhandler.ts @@ -165,17 +165,20 @@ export class SidePanelHandler extends PanelHandler { * if there is no most recently used. */ expand(id?: string): void { - if (this._currentWidget) { - this.collapse(); - } if (id) { - this.activate(id); - } else { - const visibleWidget = this.currentWidget; - if (visibleWidget) { - this._currentWidget = visibleWidget; - this.activate(visibleWidget.id); + if (this._currentWidget && this._currentWidget.id === id) { + this.collapse(); + this.hide(); + } else { + this.collapse(); + this.hide(); + this.activate(id); + this.show(); } + } else if (this.currentWidget) { + this._currentWidget = this.currentWidget; + this.activate(this._currentWidget.id); + this.show(); } }