From 4e14bc0b78d1954c21c1cc3359f83047d92b9be5 Mon Sep 17 00:00:00 2001 From: Alexandre Vryghem Date: Mon, 24 Jul 2023 23:42:55 +0200 Subject: [PATCH] 101577: Ensure the component is always destroyed before rendering the new component --- src/app/shared/theme-support/themed.component.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/app/shared/theme-support/themed.component.ts b/src/app/shared/theme-support/themed.component.ts index 3ef55be301..ded83aaf32 100644 --- a/src/app/shared/theme-support/themed.component.ts +++ b/src/app/shared/theme-support/themed.component.ts @@ -75,7 +75,6 @@ export abstract class ThemedComponent implements AfterViewInit, OnDestroy, On } ngAfterViewInit(): void { - this.destroyComponentInstance(); this.initComponentInstance(); } @@ -96,8 +95,6 @@ export abstract class ThemedComponent implements AfterViewInit, OnDestroy, On } if (hasNoValue(this.lazyLoadObs)) { - this.destroyComponentInstance(); - this.lazyLoadObs = combineLatest([ observableOf(changes), this.resolveThemedComponent(this.themeService.getThemeName()).pipe( @@ -120,6 +117,7 @@ export abstract class ThemedComponent implements AfterViewInit, OnDestroy, On } this.lazyLoadSub = this.lazyLoadObs.subscribe(([simpleChanges, constructor]: [SimpleChanges, GenericConstructor]) => { + this.destroyComponentInstance(); const factory = this.resolver.resolveComponentFactory(constructor); this.compRef = this.vcr.createComponent(factory, undefined, undefined, [this.themedElementContent.nativeElement.childNodes]); if (hasValue(simpleChanges)) {