From 46a1da6088b216eae8ac5eb038e100b6940b0ebd Mon Sep 17 00:00:00 2001 From: Anton Kosyakov Date: Mon, 29 Jul 2019 10:07:09 +0000 Subject: [PATCH] fix #5815: preserve last visible view container state otherwise collapsed view containers are not restored Signed-off-by: Anton Kosyakov --- packages/core/src/browser/view-container.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/core/src/browser/view-container.ts b/packages/core/src/browser/view-container.ts index 3536ec7491bc4..edef6bd736f4a 100644 --- a/packages/core/src/browser/view-container.ts +++ b/packages/core/src/browser/view-container.ts @@ -169,7 +169,12 @@ export class ViewContainer extends BaseWidget implements StatefulWidget, Applica return this.services.applicationStateService.state === 'ready'; } + protected lastVisibleState: ViewContainer.State | undefined; + storeState(): ViewContainer.State { + if (!this.isVisible && this.lastVisibleState) { + return this.lastVisibleState; + } const parts = this.layout.widgets; const availableSize = this.layout.getAvailableSize(); const orientation = this.orientation; @@ -345,6 +350,16 @@ export class ViewContainer extends BaseWidget implements StatefulWidget, Applica requestAnimationFrame(() => this.attached.resolve()); } + protected onBeforeHide(msg: Message): void { + super.onBeforeHide(msg); + this.lastVisibleState = this.storeState(); + } + + protected onAfterShow(msg: Message): void { + super.onAfterShow(msg); + this.lastVisibleState = undefined; + } + } export namespace ViewContainer {