@@ -16,6 +16,7 @@ import { ProxyViewContainer } from "tns-core-modules/ui/proxy-view-container/pro
1616import { AppHostView } from "../app-host-view" ;
1717import { DetachedLoader } from "../common/detached-loader" ;
1818import { PageFactory , PAGE_FACTORY } from "../platform-providers" ;
19+ import { once } from "../common/utils" ;
1920
2021export interface ModalDialogOptions {
2122 context ?: any ;
@@ -106,19 +107,17 @@ export class ModalDialogService {
106107 let componentView : View ;
107108 let detachedLoaderRef : ComponentRef < DetachedLoader > ;
108109
109- const closeCallback = ( ...args ) => {
110+ const closeCallback = once ( ( ...args ) => {
110111 doneCallback . apply ( undefined , args ) ;
111- if ( componentView && ! this . location . _isModalClosing ) {
112+ if ( componentView ) {
112113 this . location . _beginCloseModalNavigation ( ) ;
113-
114114 componentView . closeModal ( ) ;
115- } else if ( this . location . _isModalClosing ) {
116115 this . location . back ( ) ;
117116 this . location . _finishCloseModalNavigation ( ) ;
118117 detachedLoaderRef . instance . detectChanges ( ) ;
119118 detachedLoaderRef . destroy ( ) ;
120119 }
121- } ;
120+ } ) ;
122121
123122 const modalParams = new ModalDialogParams ( context , closeCallback ) ;
124123 const providers = ReflectiveInjector . resolve ( [
@@ -141,7 +140,7 @@ export class ModalDialogService {
141140 }
142141
143142 // TODO: remove <any> cast after https://github.com/NativeScript/NativeScript/pull/5734
144- // is in a published version of tns-core-modules.
143+ // is in a published version of tns-core-modules.
145144 ( < any > parentView ) . showModal ( componentView , context , closeCallback , fullscreen , animated , stretched ) ;
146145 } ) ;
147146 }
0 commit comments