Skip to content

Commit a4e393b

Browse files
committed
fix(nav): fire lifecycle events from app root portal
1 parent 8eb0667 commit a4e393b

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

src/components/modal/test/basic/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ class E2EPage {
137137
`
138138
})
139139
class NavigableModal {
140+
140141
constructor(public navCtrl: NavController) {}
141142

142143
submit() {
@@ -158,11 +159,11 @@ class NavigableModal {
158159
`
159160
})
160161
class NavigableModal2 {
161-
constructor(public navController: NavController) {
162-
}
162+
163+
constructor(public navCtrl: NavController) {}
163164

164165
submit() {
165-
this.navController.pop();
166+
this.navCtrl.pop();
166167
}
167168
}
168169

src/components/nav/nav-controller-base.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,13 @@ export class NavControllerBase extends Ion implements NavController {
193193

194194
// get the leaving view which the _insert() already set
195195
let leavingView = this.getByState(STATE_INIT_LEAVE);
196+
if (!leavingView && this._isPortal) {
197+
// if we didn't find an active view, and this is a portal
198+
let activeNav = this._app.getActiveNav();
199+
if (activeNav) {
200+
leavingView = activeNav.getByState(STATE_INIT_LEAVE);
201+
}
202+
}
196203

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

225232
// first see if there's an active view
226233
let view = this.getActive();
234+
if (!view && this._isPortal) {
235+
// if we didn't find an active view, and this is a portal
236+
let activeNav = this._app.getActiveNav();
237+
if (activeNav) {
238+
view = activeNav.getActive();
239+
}
240+
}
241+
227242
if (view) {
228243
// there's an active view, set that it's initialized to leave
229244
view.state = STATE_INIT_LEAVE;
@@ -343,6 +358,16 @@ export class NavControllerBase extends Ion implements NavController {
343358
// get the view thats ready to enter
344359
let enteringView = this.getByState(STATE_INIT_ENTER);
345360

361+
if (!enteringView && this._isPortal) {
362+
// if we didn't find an active view, and this is a portal
363+
let activeNav = this._app.getActiveNav();
364+
if (activeNav) {
365+
enteringView = activeNav.last();
366+
if (enteringView) {
367+
enteringView.state = STATE_INIT_ENTER;
368+
}
369+
}
370+
}
346371
if (!enteringView && !this._isPortal) {
347372
// oh nos! no entering view to go to!
348373
// if there is no previous view that would enter in this nav stack

src/components/nav/nav-portal.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export class NavPortal extends NavControllerBase {
2626
) {
2727
super(null, app, config, keyboard, elementRef, zone, renderer, compiler, gestureCtrl);
2828
this._isPortal = true;
29+
this._init = true;
2930
this.setViewport(viewPort);
3031
app.setPortal(this);
3132

0 commit comments

Comments
 (0)