Skip to content

Commit 873a8e1

Browse files
101577: Ensure the component is always destroyed before rendering the new component
1 parent 92f58f0 commit 873a8e1

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/app/shared/theme-support/themed.component.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ export abstract class ThemedComponent<T> implements OnInit, OnDestroy, OnChanges
6060
}
6161

6262
ngOnInit(): void {
63-
this.destroyComponentInstance();
6463
this.initComponentInstance();
6564
}
6665

@@ -81,8 +80,6 @@ export abstract class ThemedComponent<T> implements OnInit, OnDestroy, OnChanges
8180
}
8281

8382
if (hasNoValue(this.lazyLoadObs)) {
84-
this.destroyComponentInstance();
85-
8683
this.lazyLoadObs = combineLatest([
8784
observableOf(changes),
8885
this.resolveThemedComponent(this.themeService.getThemeName()).pipe(
@@ -104,6 +101,7 @@ export abstract class ThemedComponent<T> implements OnInit, OnDestroy, OnChanges
104101
}
105102

106103
this.lazyLoadSub = this.lazyLoadObs.subscribe(([simpleChanges, constructor]: [SimpleChanges, GenericConstructor<T>]) => {
104+
this.destroyComponentInstance();
107105
const factory = this.resolver.resolveComponentFactory(constructor);
108106
this.compRef = this.vcr.createComponent(factory);
109107
if (hasValue(simpleChanges)) {

0 commit comments

Comments
 (0)