Skip to content

Commit

Permalink
fix(ViewController): nav must be set as soon as possible
Browse files Browse the repository at this point in the history
fixes regression in 5a4c609
fixes #10654
  • Loading branch information
manucorporat committed Mar 5, 2017
1 parent 1dd8883 commit 61a5317
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/components/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ export class App {
present(enteringView: ViewController, opts: NavOptions, appPortal?: AppPortal): Promise<any> {
const portal = this._appRoot._getPortal(appPortal);

// Set Nav must be set here in order to dimiss() work synchnously.
// TODO: move _setNav() to the earlier stages of NavController. _queueTrns()
enteringView._setNav(portal);

opts.keyboardClose = false;
opts.direction = DIRECTION_FORWARD;

Expand Down
15 changes: 15 additions & 0 deletions src/components/loading/test/basic/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,21 @@ export class E2EPage {
this.navCtrl.push(Page2);
}, 500);
}

presentLoadingOpenDismiss() {
// debugger;
const loading = this.loadingCtrl.create({
content: 'Loading 1'
});
loading.present();
loading.dismiss();

const loading2 = this.loadingCtrl.create({
content: 'Loading 2'
});
loading2.present();
loading2.dismiss();
}
}

@Component({
Expand Down
1 change: 1 addition & 0 deletions src/components/loading/test/basic/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<button ion-button block (click)="presentLoadingMultiple()" color="danger">Multiple Loading</button>
<button ion-button block (click)="presentLoadingMultipleNav()" color="danger">Multiple Nav Loading</button>
<button ion-button block (click)="presentLoadingDismissNav()">Dismiss Page Change</button>
<button ion-button block (click)="presentLoadingOpenDismiss()">Open->Dismiss (x2)</button>

</ion-content>

Expand Down
2 changes: 1 addition & 1 deletion src/navigation/nav-controller-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ export class NavControllerBase extends Ion implements NavController {
assert(view._nav === this, 'view is not part of the nav');
this._views.splice(index, 0, this._views.splice(existingIndex, 1)[0]);
} else {
assert(!view._nav, 'nav is used');
assert(!view._nav || (this._isPortal && view._nav === this), 'nav is used');
// this is a new view to add to the stack
// create the new entering view
view._setNav(this);
Expand Down
1 change: 1 addition & 0 deletions src/navigation/view-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export class ViewController {
*/
dismiss(data?: any, role?: any, navOptions: NavOptions = {}): Promise<any> {
if (!this._nav) {
assert(this._state === ViewState.DESTROYED, 'ViewController does not have a valid _nav');
return Promise.resolve(false);
}
if (this.isOverlay && !navOptions.minClickBlockDuration) {
Expand Down

0 comments on commit 61a5317

Please sign in to comment.