Skip to content

Commit 35b7d86

Browse files
edcarrollmcosta74
authored andcommitted
fix(popup): Ensured component popups are properly destroyed
1 parent 082291f commit 35b7d86

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/modules/popup/classes/popup-component-controller.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { ComponentRef, ElementRef, Type, Renderer2 } from "@angular/core";
1+
import { ComponentRef, ElementRef, Type, Renderer2, OnDestroy } from "@angular/core";
22
import { SuiComponentFactory } from "../../../misc/util/index";
33
import { SuiPopupController } from "./popup-controller";
44
import { PopupConfig } from "./popup-config";
55

6-
export class SuiPopupComponentController<T> extends SuiPopupController {
6+
export class SuiPopupComponentController<T> extends SuiPopupController implements OnDestroy {
77
// Stores reference to generated content component.
88
private _contentComponentRef?:ComponentRef<T>;
99

@@ -37,4 +37,12 @@ export class SuiPopupComponentController<T> extends SuiPopupController {
3737

3838
super.open();
3939
}
40+
41+
public ngOnDestroy():void {
42+
if (this._contentComponentRef) {
43+
this._contentComponentRef.destroy();
44+
}
45+
46+
super.ngOnDestroy();
47+
}
4048
}

0 commit comments

Comments
 (0)