Skip to content

Commit

Permalink
fix(nav): fixes empty stack condition
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Nov 14, 2016
1 parent b937997 commit 909293a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/components/input/input-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ export class InputBase extends Ion {
// do not allow any clicks while it's scrolling
var scrollDuration = getScrollAssistDuration(scrollData.scrollAmount);
this._app.setEnabled(false, scrollDuration);
this._nav && this._nav.setTransitioning(true, scrollDuration);
this._nav && this._nav.setTransitioning(true);

// temporarily move the focus to the focus holder so the browser
// doesn't freak out while it's trying to get the input in place
Expand Down
19 changes: 10 additions & 9 deletions src/navigation/nav-controller-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,15 +335,6 @@ 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;
Expand All @@ -366,6 +357,16 @@ export class NavControllerBase extends Ion implements NavController {
opts.direction = opts.direction || DIRECTION_BACK;
}

const finalBalance = this._views.length + (insertViews ? insertViews.length : 0) - (destroyQueue ? destroyQueue.length : 0);
assert(finalBalance >= 0, 'final balance can not be negative');
if (finalBalance === 0 && !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;
}

// there are views to insert
if (insertViews) {
// manually set the new view's id if an id was passed in the options
Expand Down

0 comments on commit 909293a

Please sign in to comment.