@@ -33,6 +33,7 @@ export interface CreatedView {
3333export class SlickRowDetailView extends UniversalSlickRowDetailView {
3434 rowDetailContainer ! : ViewContainerRef ;
3535 protected _preloadComponent : Type < object > | undefined ;
36+ protected _preloadCompRef ?: ComponentRef < any > ;
3637 protected _views : CreatedView [ ] = [ ] ;
3738 protected _viewComponent ! : Type < object > ;
3839 protected _subscriptions : EventSubscription [ ] = [ ] ;
@@ -154,6 +155,9 @@ export class SlickRowDetailView extends UniversalSlickRowDetailView {
154155
155156 if ( this . onAsyncEndUpdate ) {
156157 this . eventHandler . subscribe ( this . onAsyncEndUpdate , ( e , args ) => {
158+ // destroy preload if exists
159+ this . _preloadCompRef ?. destroy ( ) ;
160+
157161 // triggers after backend called "onAsyncResponse.notify()"
158162 this . renderViewModel ( args ?. item ) ;
159163
@@ -269,10 +273,11 @@ export class SlickRowDetailView extends UniversalSlickRowDetailView {
269273 `${ PRELOAD_CONTAINER_PREFIX } `
270274 ) as HTMLCollectionOf < HTMLElement > ;
271275 if ( this . _preloadComponent && containerElements ?. length >= 0 ) {
272- this . angularUtilService . createAngularComponentAppendToDom (
276+ const preloadComp = this . angularUtilService . createAngularComponentAppendToDom (
273277 this . _preloadComponent ,
274278 containerElements [ containerElements . length - 1 ]
275279 ) ;
280+ this . _preloadCompRef = preloadComp . componentRef ;
276281 }
277282 }
278283
@@ -282,6 +287,7 @@ export class SlickRowDetailView extends UniversalSlickRowDetailView {
282287 `${ ROW_DETAIL_CONTAINER_PREFIX } ${ item [ this . datasetIdPropName ] } `
283288 ) as HTMLCollectionOf < HTMLElement > ;
284289 if ( this . _viewComponent && containerElements ?. length > 0 ) {
290+ // render row detail
285291 const componentOutput = this . angularUtilService . createAngularComponentAppendToDom (
286292 this . _viewComponent ,
287293 containerElements [ containerElements . length - 1 ] ,
@@ -312,9 +318,7 @@ export class SlickRowDetailView extends UniversalSlickRowDetailView {
312318 const compRef = expandedView ?. componentRef ;
313319 if ( compRef ) {
314320 this . appRef . detachView ( compRef . hostView ) ;
315- if ( compRef ?. destroy ) {
316- compRef . destroy ( ) ;
317- }
321+ compRef ?. destroy ( ) ;
318322 return expandedView ;
319323 }
320324 }
0 commit comments