From 8ef84b52c10e19b6639a3bfce90d7d421077eae2 Mon Sep 17 00:00:00 2001 From: Igor Katsuba Date: Fri, 24 Nov 2023 08:56:02 +0200 Subject: [PATCH] fix(cdk): add checks before destroying hostView and viewRef (#6083) --- projects/cdk/abstract/portal-service.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/projects/cdk/abstract/portal-service.ts b/projects/cdk/abstract/portal-service.ts index 5fdca5cd194e..fe13f73d5c3e 100644 --- a/projects/cdk/abstract/portal-service.ts +++ b/projects/cdk/abstract/portal-service.ts @@ -28,7 +28,9 @@ export abstract class AbstractTuiPortalService { } remove({hostView}: ComponentRef): void { - hostView.destroy(); + if (!hostView.destroyed) { + hostView.destroy(); + } } addTemplate(templateRef: TemplateRef, context?: C): EmbeddedViewRef { @@ -36,6 +38,8 @@ export abstract class AbstractTuiPortalService { } removeTemplate(viewRef: EmbeddedViewRef): void { - viewRef.destroy(); + if (!viewRef.destroyed) { + viewRef.destroy(); + } } }