From 0ab990c0155c89d0d9079c4b64c77ff244025a31 Mon Sep 17 00:00:00 2001 From: "Manu Mtz.-Almeida" Date: Fri, 4 Nov 2016 20:18:29 +0100 Subject: [PATCH] fix(nav): it is not allowed to pop all the views --- src/navigation/nav-controller-base.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/navigation/nav-controller-base.ts b/src/navigation/nav-controller-base.ts index a89950efae2..34c17eaeede 100644 --- a/src/navigation/nav-controller-base.ts +++ b/src/navigation/nav-controller-base.ts @@ -248,14 +248,15 @@ export class NavControllerBase extends Ion implements NavController { if (!ti) { return false; } - // set that this nav is actively transitioning - this.setTransitioning(true); // Get entering and leaving views const leavingView = this.getActive(); const enteringView = this._getEnteringView(ti, leavingView); - assert(leavingView || enteringView, 'Both leavingView and enteringView are null'); + assert(leavingView || enteringView, 'both leavingView and enteringView are null'); + + // set that this nav is actively transitioning + this.setTransitioning(true); // Initialize enteringView if (enteringView && isBlank(enteringView._state)) { @@ -328,6 +329,16 @@ export class NavControllerBase extends Ion implements NavController { } _postViewInit(enteringView: ViewController, leavingView: ViewController, ti: TransitionInstruction, resolve: TransitionResolveFn) { + assert(leavingView || enteringView, 'Both leavingView and enteringView are null'); + + if (!enteringView && !this._isPortal) { + console.warn(`You can't remove all the pages in the navigation stack. nav.pop() is probably called too many times.`, + this, this.getNativeElement()); + + ti.reject && ti.reject('navigation stack needs at least one root page'); + return false; + } + const opts = ti.opts || {}; const insertViews = ti.insertViews; const removeStart = ti.removeStart;