@@ -33,6 +33,7 @@ export interface CreatedView {
33
33
export class SlickRowDetailView extends UniversalSlickRowDetailView {
34
34
rowDetailContainer ! : ViewContainerRef ;
35
35
protected _preloadComponent : Type < object > | undefined ;
36
+ protected _preloadCompRef ?: ComponentRef < any > ;
36
37
protected _views : CreatedView [ ] = [ ] ;
37
38
protected _viewComponent ! : Type < object > ;
38
39
protected _subscriptions : EventSubscription [ ] = [ ] ;
@@ -154,6 +155,9 @@ export class SlickRowDetailView extends UniversalSlickRowDetailView {
154
155
155
156
if ( this . onAsyncEndUpdate ) {
156
157
this . eventHandler . subscribe ( this . onAsyncEndUpdate , ( e , args ) => {
158
+ // destroy preload if exists
159
+ this . _preloadCompRef ?. destroy ( ) ;
160
+
157
161
// triggers after backend called "onAsyncResponse.notify()"
158
162
this . renderViewModel ( args ?. item ) ;
159
163
@@ -269,10 +273,11 @@ export class SlickRowDetailView extends UniversalSlickRowDetailView {
269
273
`${ PRELOAD_CONTAINER_PREFIX } `
270
274
) as HTMLCollectionOf < HTMLElement > ;
271
275
if ( this . _preloadComponent && containerElements ?. length >= 0 ) {
272
- this . angularUtilService . createAngularComponentAppendToDom (
276
+ const preloadComp = this . angularUtilService . createAngularComponentAppendToDom (
273
277
this . _preloadComponent ,
274
278
containerElements [ containerElements . length - 1 ]
275
279
) ;
280
+ this . _preloadCompRef = preloadComp . componentRef ;
276
281
}
277
282
}
278
283
@@ -282,6 +287,7 @@ export class SlickRowDetailView extends UniversalSlickRowDetailView {
282
287
`${ ROW_DETAIL_CONTAINER_PREFIX } ${ item [ this . datasetIdPropName ] } `
283
288
) as HTMLCollectionOf < HTMLElement > ;
284
289
if ( this . _viewComponent && containerElements ?. length > 0 ) {
290
+ // render row detail
285
291
const componentOutput = this . angularUtilService . createAngularComponentAppendToDom (
286
292
this . _viewComponent ,
287
293
containerElements [ containerElements . length - 1 ] ,
@@ -312,9 +318,7 @@ export class SlickRowDetailView extends UniversalSlickRowDetailView {
312
318
const compRef = expandedView ?. componentRef ;
313
319
if ( compRef ) {
314
320
this . appRef . detachView ( compRef . hostView ) ;
315
- if ( compRef ?. destroy ) {
316
- compRef . destroy ( ) ;
317
- }
321
+ compRef ?. destroy ( ) ;
318
322
return expandedView ;
319
323
}
320
324
}
0 commit comments