Skip to content

Commit

Permalink
fix(nav): prevents to remove all views in the nav stack
Browse files Browse the repository at this point in the history
fixes #9140
  • Loading branch information
manucorporat committed Nov 28, 2016
1 parent 76df841 commit 16bfb49
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/navigation/nav-controller-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ 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);
const finalBalance = this._views.length + (insertViews ? insertViews.length : 0) - (removeCount ? removeCount : 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.`,
Expand Down
2 changes: 2 additions & 0 deletions src/navigation/test/view-controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ describe('ViewController', () => {
// arrange
let viewController = mockView();
let navControllerBase = mockNavController();
navControllerBase._isPortal = true;
mockViews(navControllerBase, [viewController]);

viewController.onDidDismiss((data: any) => {
Expand All @@ -122,6 +123,7 @@ describe('ViewController', () => {
// arrange
let viewController = mockView();
let navControllerBase = mockNavController();
navControllerBase._isPortal = true;
mockViews(navControllerBase, [viewController]);

viewController.onDidDismiss((data: any) => {
Expand Down
2 changes: 1 addition & 1 deletion src/navigation/view-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export class ViewController {
* @returns {any} data Returns the data passed in, if any.
*
*/
dismiss(data?: any, role?: any, navOptions: NavOptions = {}) {
dismiss(data?: any, role?: any, navOptions: NavOptions = {}): Promise<any> {
if (!this._nav) {
return Promise.resolve(false);
}
Expand Down

0 comments on commit 16bfb49

Please sign in to comment.