From 61a5317b25d889d859e309f79dbdb0b8d6b43b2e Mon Sep 17 00:00:00 2001 From: "Manu Mtz.-Almeida" Date: Sun, 5 Mar 2017 16:00:47 +0100 Subject: [PATCH] fix(ViewController): nav must be set as soon as possible fixes regression in 5a4c6093a72059577544dafe372e06018ee1ed19 fixes #10654 --- src/components/app/app.ts | 4 ++++ src/components/loading/test/basic/app.module.ts | 15 +++++++++++++++ src/components/loading/test/basic/main.html | 1 + src/navigation/nav-controller-base.ts | 2 +- src/navigation/view-controller.ts | 1 + 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/components/app/app.ts b/src/components/app/app.ts index 5c3fad45f93..7aee7bcccdc 100644 --- a/src/components/app/app.ts +++ b/src/components/app/app.ts @@ -220,6 +220,10 @@ export class App { present(enteringView: ViewController, opts: NavOptions, appPortal?: AppPortal): Promise { const portal = this._appRoot._getPortal(appPortal); + // Set Nav must be set here in order to dimiss() work synchnously. + // TODO: move _setNav() to the earlier stages of NavController. _queueTrns() + enteringView._setNav(portal); + opts.keyboardClose = false; opts.direction = DIRECTION_FORWARD; diff --git a/src/components/loading/test/basic/app.module.ts b/src/components/loading/test/basic/app.module.ts index f4e714156af..d1bfc536452 100644 --- a/src/components/loading/test/basic/app.module.ts +++ b/src/components/loading/test/basic/app.module.ts @@ -254,6 +254,21 @@ export class E2EPage { this.navCtrl.push(Page2); }, 500); } + + presentLoadingOpenDismiss() { + // debugger; + const loading = this.loadingCtrl.create({ + content: 'Loading 1' + }); + loading.present(); + loading.dismiss(); + + const loading2 = this.loadingCtrl.create({ + content: 'Loading 2' + }); + loading2.present(); + loading2.dismiss(); + } } @Component({ diff --git a/src/components/loading/test/basic/main.html b/src/components/loading/test/basic/main.html index 4f86675fe4a..182d7cfd9a1 100644 --- a/src/components/loading/test/basic/main.html +++ b/src/components/loading/test/basic/main.html @@ -22,6 +22,7 @@ + diff --git a/src/navigation/nav-controller-base.ts b/src/navigation/nav-controller-base.ts index c379f0a1bb0..a9486e598aa 100644 --- a/src/navigation/nav-controller-base.ts +++ b/src/navigation/nav-controller-base.ts @@ -775,7 +775,7 @@ export class NavControllerBase extends Ion implements NavController { assert(view._nav === this, 'view is not part of the nav'); this._views.splice(index, 0, this._views.splice(existingIndex, 1)[0]); } else { - assert(!view._nav, 'nav is used'); + assert(!view._nav || (this._isPortal && view._nav === this), 'nav is used'); // this is a new view to add to the stack // create the new entering view view._setNav(this); diff --git a/src/navigation/view-controller.ts b/src/navigation/view-controller.ts index 5b98ac90258..068e25d0f77 100644 --- a/src/navigation/view-controller.ts +++ b/src/navigation/view-controller.ts @@ -165,6 +165,7 @@ export class ViewController { */ dismiss(data?: any, role?: any, navOptions: NavOptions = {}): Promise { if (!this._nav) { + assert(this._state === ViewState.DESTROYED, 'ViewController does not have a valid _nav'); return Promise.resolve(false); } if (this.isOverlay && !navOptions.minClickBlockDuration) {