Skip to content

Commit 61a5317

Browse files
committed
fix(ViewController): nav must be set as soon as possible
fixes regression in 5a4c609 fixes #10654
1 parent 1dd8883 commit 61a5317

File tree

5 files changed

+22
-1
lines changed

5 files changed

+22
-1
lines changed

src/components/app/app.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@ export class App {
220220
present(enteringView: ViewController, opts: NavOptions, appPortal?: AppPortal): Promise<any> {
221221
const portal = this._appRoot._getPortal(appPortal);
222222

223+
// Set Nav must be set here in order to dimiss() work synchnously.
224+
// TODO: move _setNav() to the earlier stages of NavController. _queueTrns()
225+
enteringView._setNav(portal);
226+
223227
opts.keyboardClose = false;
224228
opts.direction = DIRECTION_FORWARD;
225229

src/components/loading/test/basic/app.module.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,21 @@ export class E2EPage {
254254
this.navCtrl.push(Page2);
255255
}, 500);
256256
}
257+
258+
presentLoadingOpenDismiss() {
259+
// debugger;
260+
const loading = this.loadingCtrl.create({
261+
content: 'Loading 1'
262+
});
263+
loading.present();
264+
loading.dismiss();
265+
266+
const loading2 = this.loadingCtrl.create({
267+
content: 'Loading 2'
268+
});
269+
loading2.present();
270+
loading2.dismiss();
271+
}
257272
}
258273

259274
@Component({

src/components/loading/test/basic/main.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<button ion-button block (click)="presentLoadingMultiple()" color="danger">Multiple Loading</button>
2323
<button ion-button block (click)="presentLoadingMultipleNav()" color="danger">Multiple Nav Loading</button>
2424
<button ion-button block (click)="presentLoadingDismissNav()">Dismiss Page Change</button>
25+
<button ion-button block (click)="presentLoadingOpenDismiss()">Open->Dismiss (x2)</button>
2526

2627
</ion-content>
2728

src/navigation/nav-controller-base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ export class NavControllerBase extends Ion implements NavController {
775775
assert(view._nav === this, 'view is not part of the nav');
776776
this._views.splice(index, 0, this._views.splice(existingIndex, 1)[0]);
777777
} else {
778-
assert(!view._nav, 'nav is used');
778+
assert(!view._nav || (this._isPortal && view._nav === this), 'nav is used');
779779
// this is a new view to add to the stack
780780
// create the new entering view
781781
view._setNav(this);

src/navigation/view-controller.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ export class ViewController {
165165
*/
166166
dismiss(data?: any, role?: any, navOptions: NavOptions = {}): Promise<any> {
167167
if (!this._nav) {
168+
assert(this._state === ViewState.DESTROYED, 'ViewController does not have a valid _nav');
168169
return Promise.resolve(false);
169170
}
170171
if (this.isOverlay && !navOptions.minClickBlockDuration) {

0 commit comments

Comments
 (0)