Skip to content

Commit aa924fd

Browse files
MKirovaMKirova
authored andcommitted
fix(igxGrid): Reset autogenerated columns in case Ivy triggers a ContentChildren re-evaluation that clears them.
1 parent 3b8edda commit aa924fd

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2468,6 +2468,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
24682468
private _unpinnedWidth = NaN;
24692469
private _visibleColumns = [];
24702470
private _columnGroups = false;
2471+
private _autoGeneratedCols = [];
24712472
protected _headerFeaturesWidth = NaN;
24722473

24732474
private _columnWidth: string;
@@ -4543,10 +4544,16 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
45434544
*/
45444545
protected onColumnsChanged(change: QueryList<IgxColumnComponent>) {
45454546
const diff = this.columnListDiffer.diff(change);
4547+
if (this.autoGenerate && this.columnList.length === 0 && this._autoGeneratedCols.length > 0) {
4548+
// In Ivy if there are nested conditional templates the content children are re-evaluated
4549+
// hence autogenerated columns are cleared and need to be reset.
4550+
this.columnList.reset(this._autoGeneratedCols);
4551+
return;
4552+
}
45464553
if (diff) {
45474554
let added = false;
45484555
let removed = false;
4549-
4556+
45504557
this.initColumns(this.columnList);
45514558

45524559

@@ -4772,6 +4779,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
47724779
ref.changeDetectorRef.detectChanges();
47734780
columns.push(ref.instance);
47744781
});
4782+
this._autoGeneratedCols = columns;
47754783

47764784
this.columnList.reset(columns);
47774785
if (data && data.length > 0) {

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ export class IgxHierarchicalGridComponent extends IgxHierarchicalGridBaseDirecti
417417
protected onColumnsChanged(change: QueryList<IgxColumnComponent>) {
418418
this.updateColumnList();
419419
const cols = change.filter(c => c.gridAPI.grid === this);
420-
if (cols.length > 0) {
420+
if (cols.length > 0 || this.autoGenerate) {
421421
this.columnList.reset(cols);
422422
super.onColumnsChanged(this.columnList);
423423
}

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,8 +1080,7 @@ describe('IgxHierarchicalGrid Runtime Row Island change Scenarios #hGrid', () =>
10801080
hierarchicalGrid = fixture.componentInstance.hgrid;
10811081
}));
10821082

1083-
xit('should allow changing row islands runtime in root grid.', () => {
1084-
pending('Related to issue #6731');
1083+
it('should allow changing row islands runtime in root grid.', () => {
10851084
const row = hierarchicalGrid.getRowByIndex(0) as IgxHierarchicalRowComponent;
10861085
UIInteractions.clickElement(row.expander);
10871086
fixture.detectChanges();

0 commit comments

Comments
 (0)