Skip to content

Commit e2704a4

Browse files
committed
fix(modal): alerts do not trigger modal lifecycle events
fixes #8616
1 parent c996d85 commit e2704a4

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/components/app/app-root.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const AppRootToken = new OpaqueToken('USERROOT');
1515
selector: 'ion-app',
1616
template:
1717
'<div #viewport app-viewport></div>' +
18+
'<div #modalPortal overlay-portal></div>' +
1819
'<div #overlayPortal overlay-portal></div>' +
1920
'<div #loadingPortal class="loading-portal" overlay-portal></div>' +
2021
'<div #toastPortal class="toast-portal" overlay-portal></div>' +
@@ -24,6 +25,8 @@ export class IonicApp extends Ion implements OnInit {
2425

2526
@ViewChild('viewport', {read: ViewContainerRef}) _viewport: ViewContainerRef;
2627

28+
@ViewChild('modalPortal', { read: OverlayPortal }) _modalPortal: OverlayPortal;
29+
2730
@ViewChild('overlayPortal', { read: OverlayPortal }) _overlayPortal: OverlayPortal;
2831

2932
@ViewChild('loadingPortal', { read: OverlayPortal }) _loadingPortal: OverlayPortal;
@@ -96,6 +99,9 @@ export class IonicApp extends Ion implements OnInit {
9699
if (portal === AppPortal.TOAST) {
97100
return this._toastPortal;
98101
}
102+
if (portal === AppPortal.MODAL) {
103+
return this._modalPortal;
104+
}
99105
return this._overlayPortal;
100106
}
101107

@@ -110,6 +116,7 @@ export class IonicApp extends Ion implements OnInit {
110116

111117
export enum AppPortal {
112118
DEFAULT,
119+
MODAL,
113120
LOADING,
114121
TOAST
115122
};

src/components/modal/modal.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Injectable } from '@angular/core';
22

33
import { App } from '../app/app';
4+
import { AppPortal } from '../app/app-root';
45
import { isPresent } from '../../util/util';
56
import { ModalCmp } from './modal-component';
67
import { ModalOptions } from './modal-options';
@@ -40,7 +41,7 @@ export class Modal extends ViewController {
4041
* @returns {Promise} Returns a promise which is resolved when the transition has completed.
4142
*/
4243
present(navOptions: NavOptions = {}) {
43-
return this._app.present(this, navOptions);
44+
return this._app.present(this, navOptions, AppPortal.MODAL);
4445
}
4546

4647
/**

0 commit comments

Comments
 (0)