Skip to content

Commit 13053be

Browse files
MKirovaMKirova
authored andcommitted
chore(*): Apply review comments.
1 parent 560f034 commit 13053be

File tree

3 files changed

+9
-24
lines changed

3 files changed

+9
-24
lines changed

projects/igniteui-angular-elements/src/app/custom-strategy.ts

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,10 @@ class IgxCustomNgElementStrategy extends ComponentNgElementStrategy {
7171
// TODO: special registration OR config for custom
7272
}
7373

74-
const promises = [];
75-
for (const contentChild of contentChildren) {
76-
// these resolve after the parent, both the components needs to be initialized and the parent query schedule should complete before it is really ready.
77-
const child = contentChild as IgcNgElement;
78-
const promiseComponentReady = this.waitForCondition(() => (child.ngElementStrategy as any)?.componentRef && this.schedule.size == 0);
79-
promises.push(promiseComponentReady);
74+
if (contentChildren.length === 0) {
75+
// no content children, emit event immediately, since there's nothing to be attached.
76+
(this as any).componentRef?.instance?.childrenAttached?.emit();
8077
}
81-
Promise.all(promises).then(() => {
82-
(this as any).componentRef?.instance.contentChildrenReady.emit();
83-
});
8478

8579
let parentInjector: Injector;
8680
let parentAnchor: ViewContainerRef;
@@ -224,19 +218,6 @@ class IgxCustomNgElementStrategy extends ComponentNgElementStrategy {
224218
}
225219
}
226220

227-
public waitForCondition(conditionFn: any, interval = 10) {
228-
return new Promise<void>((resolve) => {
229-
function checkCondition() {
230-
if (conditionFn()) {
231-
resolve();
232-
} else {
233-
setTimeout(checkCondition, interval);
234-
}
235-
}
236-
checkCondition();
237-
});
238-
}
239-
240221
public override setInputValue(property: string, value: any, transform?: (value: any) => any): void {
241222
if ((this as any).componentRef === null ||
242223
!(this as any).componentRef.instance) {
@@ -333,6 +314,10 @@ class IgxCustomNgElementStrategy extends ComponentNgElementStrategy {
333314
list.reset(childRefs);
334315
list.notifyOnChanges();
335316
}
317+
if (this.schedule.size === 0) {
318+
// children are attached and collections are updated, emit event.
319+
(this as any).componentRef?.instance?.childrenAttached?.emit();
320+
}
336321
}
337322

338323
private runQueryInDOM(element: HTMLElement, query: ContentQueryMeta): IgcNgElement[] {

projects/igniteui-angular-elements/src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ <h3 class="ig-typography__h6">Flat Grid (MRL column layout)</h3>
131131

132132
grid1.data = northwindProducts;
133133
grid2.data = northwindProducts;
134-
grid1.addEventListener('contentChildrenReady', () => {
134+
grid1.addEventListener('childrenAttached', () => {
135135
console.log("Ready!");
136136
restoreState();
137137
});

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ export abstract class IgxGridBaseDirective implements GridType,
10061006
* Emitted when content children are attached and collections in grid are updated.
10071007
*/
10081008
@Output()
1009-
public contentChildrenReady = new EventEmitter<void>();
1009+
public childrenAttached = new EventEmitter<void>();
10101010

10111011
/**
10121012
* Emitted when the expanded state of a row gets changed.

0 commit comments

Comments
 (0)