@@ -2,7 +2,6 @@ import { ApplicationRef, ComponentRef, Injectable, Injector, NgModuleRef, NgZone
22import { Application , ContentView , Frame , ShowModalOptions , View , ViewBase } from '@nativescript/core' ;
33import { Subject } from 'rxjs' ;
44import { AppHostAsyncView , AppHostView } from '../../app-host-view' ;
5- import { DetachedLoader } from '../../cdk/detached-loader' ;
65import { ComponentPortal } from '../../cdk/portal/common' ;
76import { NativeScriptDomPortalOutlet } from '../../cdk/portal/nsdom-portal-outlet' ;
87import { didModalOpen , once } from '../../utils/general' ;
@@ -117,7 +116,6 @@ export class ModalDialogService {
117116
118117 private _showDialog ( options : ShowDialogOptions ) : void {
119118 let componentViewRef : NgViewRef < unknown > ;
120- let detachedLoaderRef : ComponentRef < DetachedLoader > ;
121119 let portalOutlet : NativeScriptDomPortalOutlet ;
122120
123121 const closeCallback = once ( async ( ...args ) => {
@@ -129,11 +127,9 @@ export class ModalDialogService {
129127 this . _closed$ . next ( params ) ;
130128 }
131129 await this . location . _closeModalNavigation ( ) ;
132- if ( detachedLoaderRef || portalOutlet ) {
130+ if ( portalOutlet ) {
133131 this . zone . run ( ( ) => {
134132 portalOutlet ?. dispose ( ) ;
135- detachedLoaderRef ?. instance . detectChanges ( ) ;
136- detachedLoaderRef ?. destroy ( ) ;
137133 } ) ;
138134 }
139135 }
@@ -169,7 +165,7 @@ export class ModalDialogService {
169165 const modalView = componentViewRef . firstNativeLikeView ;
170166 options . parentView . showModal ( modalView , { ...options , closeCallback } ) ;
171167 if ( ! didModalOpen ( options . parentView as View , modalView ) ) {
172- this . _handleFailedOpen ( modalParams , portalOutlet , detachedLoaderRef ) ;
168+ this . _handleFailedOpen ( modalParams , portalOutlet ) ;
173169 }
174170 } ) ;
175171 }
@@ -179,15 +175,13 @@ export class ModalDialogService {
179175 * failed to actually present it. Without this the modal navigation stack stays incremented
180176 * (blocking further navigation) and the attached view/loader leak on the `ApplicationRef`.
181177 */
182- private _handleFailedOpen ( modalParams : ModalDialogParams , portalOutlet ?: NativeScriptDomPortalOutlet , detachedLoaderRef ?: ComponentRef < DetachedLoader > ) : never {
178+ private _handleFailedOpen ( modalParams : ModalDialogParams , portalOutlet ?: NativeScriptDomPortalOutlet ) : never {
183179 const index = this . openedModalParams ?. indexOf ( modalParams ) ?? - 1 ;
184180 if ( index > - 1 ) {
185181 this . openedModalParams . splice ( index , 1 ) ;
186182 }
187183 this . location ?. _closeModalNavigation ( ) ;
188184 portalOutlet ?. dispose ( ) ;
189- detachedLoaderRef ?. instance . detectChanges ( ) ;
190- detachedLoaderRef ?. destroy ( ) ;
191185 throw new Error ( 'Failed to open dialog: the modal view could not be presented. This usually happens when another modal is already being presented.' ) ;
192186 }
193187}
0 commit comments