Skip to content

Commit

Permalink
fix(overlay): onWillDismiss is called as expected (#12056)
Browse files Browse the repository at this point in the history
* fix(overlay): onWillDismiss is called as expected

fixes #11702

* Fix condition
  • Loading branch information
manucorporat authored Oct 6, 2017
1 parent b180351 commit c91223b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
17 changes: 11 additions & 6 deletions src/navigation/nav-controller-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,10 @@ export class NavControllerBase extends Ion implements NavController {
if (enteringView || leavingView) {
this._zone.run(() => {
// Here, the order is important. WillLeave must be called before WillEnter.
leavingView && this._willLeave(leavingView, !enteringView);
if (leavingView) {
const willUnload = enteringView ? leavingView.index > enteringView.index : true;
this._willLeave(leavingView, willUnload);
}
enteringView && this._willEnter(enteringView);
});
}
Expand Down Expand Up @@ -858,9 +861,12 @@ export class NavControllerBase extends Ion implements NavController {
_cleanup(activeView: ViewController) {
// ok, cleanup time!! Destroy all of the views that are
// INACTIVE and come after the active view

// only do this if the views exist, though
if (!this._destroyed) {
const activeViewIndex = this._views.indexOf(activeView);
assert(activeViewIndex >= 0, 'active index is invalid');

const views = this._views;
let reorderZIndexes = false;
let view: ViewController;
Expand Down Expand Up @@ -1121,7 +1127,8 @@ export class NavControllerBase extends Ion implements NavController {
view = this.getActive();
}
const views = this._views;
return views[views.indexOf(view) - 1];
const index = views.indexOf(view);
return (index > 0) ? views[index - 1] : null;
}

first(): ViewController {
Expand All @@ -1131,7 +1138,8 @@ export class NavControllerBase extends Ion implements NavController {

last(): ViewController {
// returns the last page in this nav controller's stack.
return this._views[this._views.length - 1];
const views = this._views;
return views[views.length - 1];
}

indexOf(view: ViewController): number {
Expand All @@ -1143,9 +1151,6 @@ export class NavControllerBase extends Ion implements NavController {
return this._views.length;
}

/**
* Return the stack of views in this NavController.
*/
getViews(): Array<ViewController> {
return this._views;
}
Expand Down
1 change: 0 additions & 1 deletion src/navigation/nav-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,6 @@ export abstract class NavController implements NavigationContainer {
*/
abstract length(): number;


/**
* Returns the current stack of views in this nav controller.
* @returns {Array<ViewController>} the stack of view controllers in this nav controller.
Expand Down

0 comments on commit c91223b

Please sign in to comment.