@@ -41,14 +41,14 @@ class IgxCustomNgElementStrategy extends ComponentNgElementStrategy {
41
41
*/
42
42
public [ ComponentRefKey ] = new Promise < ComponentRef < any > > ( ( resolve , _ ) => this . setComponentRef = resolve ) ;
43
43
44
- private _templateWrapper : TemplateWrapperComponent ;
44
+ private _templateWrapperRef : ComponentRef < TemplateWrapperComponent > ;
45
45
protected get templateWrapper ( ) : TemplateWrapperComponent {
46
- if ( ! this . _templateWrapper ) {
46
+ if ( ! this . _templateWrapperRef ) {
47
47
const componentRef = ( this as any ) . componentRef as ComponentRef < any > ;
48
48
const viewRef = componentRef . injector . get ( ViewContainerRef ) ;
49
- this . _templateWrapper = viewRef . createComponent ( TemplateWrapperComponent ) . instance ;
49
+ this . _templateWrapperRef = viewRef . createComponent ( TemplateWrapperComponent ) ;
50
50
}
51
- return this . _templateWrapper ;
51
+ return this . _templateWrapperRef . instance ;
52
52
}
53
53
54
54
private _configSelectors : string ;
@@ -63,7 +63,7 @@ class IgxCustomNgElementStrategy extends ComponentNgElementStrategy {
63
63
super ( _componentFactory , _injector ) ;
64
64
}
65
65
66
- override async initializeComponent ( element : HTMLElement ) {
66
+ protected override async initializeComponent ( element : HTMLElement ) {
67
67
if ( ! element . isConnected ) {
68
68
// D.P. 2022-09-20 do not initialize on connectedCallback that is not actually connected
69
69
// connectedCallback may be called once your element is no longer connected
@@ -113,15 +113,15 @@ class IgxCustomNgElementStrategy extends ComponentNgElementStrategy {
113
113
// ngElementStrategy getter is protected and also has initialization logic, though that should be safe at this point
114
114
if ( parent ?. ngElementStrategy ) {
115
115
this . angularParent = parent . ngElementStrategy . angularParent ;
116
- const parentComponentRef = await parent ?. ngElementStrategy [ ComponentRefKey ] ;
116
+ let parentComponentRef = await parent ?. ngElementStrategy [ ComponentRefKey ] ;
117
117
parentInjector = parentComponentRef ?. injector ;
118
118
119
119
// TODO: Consider general solution (as in Parent w/ @igxAnchor tag)
120
120
if ( element . tagName . toLocaleLowerCase ( ) === 'igc-grid-toolbar'
121
121
|| element . tagName . toLocaleLowerCase ( ) === 'igc-paginator' ) {
122
122
// NOPE: viewcontainerRef will re-render this node again, no option for rootNode :S
123
123
// this.componentRef = parentAnchor.createComponent(this.componentFactory.componentType, { projectableNodes, injector: childInjector });
124
- const parentComponentRef = await parent ?. ngElementStrategy [ ComponentRefKey ] ;
124
+ parentComponentRef = await parent ?. ngElementStrategy [ ComponentRefKey ] ;
125
125
parentAnchor = parentComponentRef ?. instance . anchor ;
126
126
}
127
127
} else if ( ( parent as any ) ?. __componentRef ) {
@@ -220,6 +220,14 @@ class IgxCustomNgElementStrategy extends ComponentNgElementStrategy {
220
220
if ( [ 'igc-grid' , 'igc-tree-grid' , 'igc-hierarchical-grid' ] . includes ( element . tagName . toLocaleLowerCase ( ) ) ) {
221
221
this . patchGridPopups ( ) ;
222
222
}
223
+
224
+ // instead of duplicating super.disconnect() w/ the scheduled destroy:
225
+ componentRef . onDestroy ( ( ) => {
226
+ if ( this . _templateWrapperRef ) {
227
+ this . _templateWrapperRef . destroy ( ) ;
228
+ this . _templateWrapperRef = null ;
229
+ }
230
+ } ) ;
223
231
}
224
232
225
233
public override setInputValue ( property : string , value : any , transform ?: ( value : any ) => any ) : void {
@@ -354,17 +362,6 @@ class IgxCustomNgElementStrategy extends ComponentNgElementStrategy {
354
362
}
355
363
//#endregion schedule query update
356
364
357
- /**
358
- * assignTemplateCallback
359
- */
360
- public assignTemplateCallback ( templateProp : string , callback : any ) {
361
- const componentRef = ( this as any ) . componentRef as ComponentRef < any > ;
362
- if ( componentRef ) {
363
- const templateRef = this . templateWrapper . addTemplate ( callback ) ;
364
- componentRef . instance [ templateProp ] = templateRef ;
365
- componentRef . changeDetectorRef . detectChanges ( ) ;
366
- }
367
- }
368
365
369
366
//#region Grid popups hide on scroll
370
367
/**
@@ -400,7 +397,7 @@ class IgxCustomNgElementStrategy extends ComponentNgElementStrategy {
400
397
}
401
398
//#endregion
402
399
403
- override disconnect ( ) : void {
400
+ public override disconnect ( ) : void {
404
401
if ( this . angularParent ) {
405
402
this . angularParent . onDestroy ( ( ) => super . disconnect ( ) ) ;
406
403
} else {
0 commit comments