Skip to content

fix(elements): Do not destroy elements inside tmpl wrapper on detach. #15679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions projects/igniteui-angular-elements/src/app/custom-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,18 @@ class IgxCustomNgElementStrategy extends ComponentNgElementStrategy {
}
value = this.templateWrapper.addTemplate(value);
// TODO: discard oldValue

// check template for any angular-element components
this.templateWrapper.templateRendered.subscribe((element) => {
const igComponents = this.config.flatMap(x => [
x.selector,
reflectComponentType(x.component).selector
]).join(',');
const children = element.querySelectorAll(igComponents);
children?.forEach((c) => {
c.ngElementStrategy.angularParent = componentRef;
});
});
}
if (componentRef && componentConfig?.boolProps?.includes(property)) {
// bool coerce:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeDetectorRef, Component, QueryList, TemplateRef, ViewChildren } from '@angular/core';
import { ChangeDetectorRef, Component, EventEmitter, QueryList, TemplateRef, ViewChildren } from '@angular/core';
import { TemplateRefWrapper } from './template-ref-wrapper';

import { render, TemplateResult } from 'lit-html';
Expand All @@ -14,6 +14,7 @@ type TemplateFunction = (arg: any) => TemplateResult;
export class TemplateWrapperComponent {

public templateFunctions: TemplateFunction[] = [];
public templateRendered = new EventEmitter<any>();

/**
* All template refs
Expand All @@ -27,6 +28,7 @@ export class TemplateWrapperComponent {

public litRender(container: HTMLElement, templateFunc: (arg: any) => TemplateResult, arg: any) {
render(templateFunc(arg), container);
this.templateRendered.emit(container);
}

public addTemplate(templateFunc: TemplateFunction): TemplateRef<any> {
Expand Down
6 changes: 5 additions & 1 deletion projects/igniteui-angular-elements/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,11 @@ <h3 class="ig-typography__h6">Flat Grid (MRL column layout)</h3>
<igc-combo ${ref(focusCallback)} style="width:100%; height:100%" .data=${northwindProducts} value-key="ProductName" @igcChange=${(e) => ctx.cell.editValue = e.detail.newValue} single-select>
</igc-combo>
`;
grid1.detailTemplate = (ctx) => html`<div><span class="categoryStyle">Stock: ${ctx.implicit.InStock}</span></div>`;
grid1.detailTemplate = (ctx) => {
return html`<div>
<igc-grid auto-generate="true"></igc-grid>
</div>`;
}

grid2.querySelector('igc-column[field="ProductName"]').inlineEditorTemplate = (ctx) =>
html`
Expand Down
Loading