Skip to content

Commit

Permalink
fix(nav): fire lifecycle events from app root portal
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Aug 5, 2016
1 parent 8eb0667 commit a4e393b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/components/modal/test/basic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class E2EPage {
`
})
class NavigableModal {

constructor(public navCtrl: NavController) {}

submit() {
Expand All @@ -158,11 +159,11 @@ class NavigableModal {
`
})
class NavigableModal2 {
constructor(public navController: NavController) {
}

constructor(public navCtrl: NavController) {}

submit() {
this.navController.pop();
this.navCtrl.pop();
}
}

Expand Down
25 changes: 25 additions & 0 deletions src/components/nav/nav-controller-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,13 @@ export class NavControllerBase extends Ion implements NavController {

// get the leaving view which the _insert() already set
let leavingView = this.getByState(STATE_INIT_LEAVE);
if (!leavingView && this._isPortal) {
// if we didn't find an active view, and this is a portal
let activeNav = this._app.getActiveNav();
if (activeNav) {
leavingView = activeNav.getByState(STATE_INIT_LEAVE);
}
}

// start the transition, fire resolve when done...
this._transition(enteringView, leavingView, opts, done);
Expand Down Expand Up @@ -224,6 +231,14 @@ export class NavControllerBase extends Ion implements NavController {

// first see if there's an active view
let view = this.getActive();
if (!view && this._isPortal) {
// if we didn't find an active view, and this is a portal
let activeNav = this._app.getActiveNav();
if (activeNav) {
view = activeNav.getActive();
}
}

if (view) {
// there's an active view, set that it's initialized to leave
view.state = STATE_INIT_LEAVE;
Expand Down Expand Up @@ -343,6 +358,16 @@ export class NavControllerBase extends Ion implements NavController {
// get the view thats ready to enter
let enteringView = this.getByState(STATE_INIT_ENTER);

if (!enteringView && this._isPortal) {
// if we didn't find an active view, and this is a portal
let activeNav = this._app.getActiveNav();
if (activeNav) {
enteringView = activeNav.last();
if (enteringView) {
enteringView.state = STATE_INIT_ENTER;
}
}
}
if (!enteringView && !this._isPortal) {
// oh nos! no entering view to go to!
// if there is no previous view that would enter in this nav stack
Expand Down
1 change: 1 addition & 0 deletions src/components/nav/nav-portal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class NavPortal extends NavControllerBase {
) {
super(null, app, config, keyboard, elementRef, zone, renderer, compiler, gestureCtrl);
this._isPortal = true;
this._init = true;
this.setViewport(viewPort);
app.setPortal(this);

Expand Down

0 comments on commit a4e393b

Please sign in to comment.