Skip to content

fix(overlay): onWillDismiss is called as expected #12056

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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