Skip to content

Commit 24443c3

Browse files
committed
fix(ViewController): call onDismiss after transition ends
Closes #5818
1 parent fe04c51 commit 24443c3

File tree

3 files changed

+85
-2
lines changed

3 files changed

+85
-2
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { Alert, NavController, App, Page } from 'ionic-angular/index';
2+
3+
4+
@Page({
5+
templateUrl: 'main.html'
6+
})
7+
export class E2EPage {
8+
9+
constructor(private nav: NavController) {}
10+
11+
submit() {
12+
var alert = Alert.create({
13+
title: 'Not logged in',
14+
message: 'Sign in to continue.',
15+
buttons: [
16+
{
17+
text: 'Cancel',
18+
role: 'cancel'
19+
},
20+
{
21+
text: 'Sign in',
22+
handler: () => {
23+
console.log('Sign in');
24+
}
25+
}
26+
]
27+
});
28+
29+
alert.onDismiss((asdf) => {
30+
console.log('dismiss');
31+
this.nav.push(AnotherPage);
32+
});
33+
34+
this.nav.present(alert);
35+
}
36+
}
37+
38+
@Page({
39+
template: `
40+
<ion-navbar *navbar>
41+
<ion-title>Another Page</ion-title>
42+
</ion-navbar>
43+
<ion-content padding>
44+
Welcome!
45+
</ion-content>
46+
`
47+
})
48+
class AnotherPage {}
49+
50+
51+
@App({
52+
template: '<ion-nav [root]="root"></ion-nav>'
53+
})
54+
class E2EApp {
55+
root;
56+
constructor() {
57+
this.root = E2EPage;
58+
}
59+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<ion-navbar *navbar>
2+
<ion-title>
3+
Alert Dismiss
4+
</ion-title>
5+
</ion-navbar>
6+
7+
<ion-content>
8+
9+
<ion-list>
10+
<ion-item>
11+
<ion-label floating>Input text here</ion-label>
12+
<ion-input type="text"></ion-input>
13+
</ion-item>
14+
</ion-list>
15+
16+
<div padding>
17+
<button primary block (click)="submit()">
18+
Submit
19+
</button>
20+
</div>
21+
22+
</ion-content>

ionic/components/nav/view-controller.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@ export class ViewController {
108108
}
109109

110110
dismiss(data?: any, role?: any) {
111-
this._onDismiss && this._onDismiss(data, role);
112-
return this._nav.remove(this._nav.indexOf(this), 1, this._leavingOpts);
111+
return this._nav.remove(this._nav.indexOf(this), 1, this._leavingOpts).then(() => {
112+
this._onDismiss && this._onDismiss(data, role);
113+
return data;
114+
});
113115
}
114116

115117
/**

0 commit comments

Comments
 (0)