Skip to content

Commit 909293a

Browse files
committed
fix(nav): fixes empty stack condition
1 parent b937997 commit 909293a

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/components/input/input-base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ export class InputBase extends Ion {
340340
// do not allow any clicks while it's scrolling
341341
var scrollDuration = getScrollAssistDuration(scrollData.scrollAmount);
342342
this._app.setEnabled(false, scrollDuration);
343-
this._nav && this._nav.setTransitioning(true, scrollDuration);
343+
this._nav && this._nav.setTransitioning(true);
344344

345345
// temporarily move the focus to the focus holder so the browser
346346
// doesn't freak out while it's trying to get the input in place

src/navigation/nav-controller-base.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -335,15 +335,6 @@ export class NavControllerBase extends Ion implements NavController {
335335

336336
_postViewInit(enteringView: ViewController, leavingView: ViewController, ti: TransitionInstruction, resolve: TransitionResolveFn) {
337337
assert(leavingView || enteringView, 'Both leavingView and enteringView are null');
338-
339-
if (!enteringView && !this._isPortal) {
340-
console.warn(`You can't remove all the pages in the navigation stack. nav.pop() is probably called too many times.`,
341-
this, this.getNativeElement());
342-
343-
ti.reject && ti.reject('navigation stack needs at least one root page');
344-
return false;
345-
}
346-
347338
const opts = ti.opts || {};
348339
const insertViews = ti.insertViews;
349340
const removeStart = ti.removeStart;
@@ -366,6 +357,16 @@ export class NavControllerBase extends Ion implements NavController {
366357
opts.direction = opts.direction || DIRECTION_BACK;
367358
}
368359

360+
const finalBalance = this._views.length + (insertViews ? insertViews.length : 0) - (destroyQueue ? destroyQueue.length : 0);
361+
assert(finalBalance >= 0, 'final balance can not be negative');
362+
if (finalBalance === 0 && !this._isPortal) {
363+
console.warn(`You can't remove all the pages in the navigation stack. nav.pop() is probably called too many times.`,
364+
this, this.getNativeElement());
365+
366+
ti.reject && ti.reject('navigation stack needs at least one root page');
367+
return false;
368+
}
369+
369370
// there are views to insert
370371
if (insertViews) {
371372
// manually set the new view's id if an id was passed in the options

0 commit comments

Comments
 (0)