Skip to content

Commit 0ab990c

Browse files
committed
fix(nav): it is not allowed to pop all the views
1 parent 5f1a862 commit 0ab990c

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/navigation/nav-controller-base.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,15 @@ export class NavControllerBase extends Ion implements NavController {
248248
if (!ti) {
249249
return false;
250250
}
251-
// set that this nav is actively transitioning
252-
this.setTransitioning(true);
253251

254252
// Get entering and leaving views
255253
const leavingView = this.getActive();
256254
const enteringView = this._getEnteringView(ti, leavingView);
257255

258-
assert(leavingView || enteringView, 'Both leavingView and enteringView are null');
256+
assert(leavingView || enteringView, 'both leavingView and enteringView are null');
257+
258+
// set that this nav is actively transitioning
259+
this.setTransitioning(true);
259260

260261
// Initialize enteringView
261262
if (enteringView && isBlank(enteringView._state)) {
@@ -328,6 +329,16 @@ export class NavControllerBase extends Ion implements NavController {
328329
}
329330

330331
_postViewInit(enteringView: ViewController, leavingView: ViewController, ti: TransitionInstruction, resolve: TransitionResolveFn) {
332+
assert(leavingView || enteringView, 'Both leavingView and enteringView are null');
333+
334+
if (!enteringView && !this._isPortal) {
335+
console.warn(`You can't remove all the pages in the navigation stack. nav.pop() is probably called too many times.`,
336+
this, this.getNativeElement());
337+
338+
ti.reject && ti.reject('navigation stack needs at least one root page');
339+
return false;
340+
}
341+
331342
const opts = ti.opts || {};
332343
const insertViews = ti.insertViews;
333344
const removeStart = ti.removeStart;

0 commit comments

Comments
 (0)