Skip to content

Commit 77ecffb

Browse files
committed
fix(forOf): Do not interact with sync service if having unique size cache.
1 parent 1f0264e commit 77ecffb

2 files changed

Lines changed: 29 additions & 8 deletions

File tree

projects/igniteui-angular/directives/src/directives/for-of/for_of.directive.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,7 +1672,9 @@ export class IgxGridForOfDirective<T, U extends T[] = T[]> extends IgxForOfDirec
16721672
}
16731673

16741674
public override ngOnInit() {
1675-
this.syncService.setMaster(this);
1675+
if (!this.igxGridForOfUniqueSizeCache) {
1676+
this.syncService.setMaster(this);
1677+
}
16761678
super.ngOnInit();
16771679
this.removeScrollEventListeners();
16781680
const destructor = takeUntil<any>(this.destroy$);
@@ -1685,7 +1687,9 @@ export class IgxGridForOfDirective<T, U extends T[] = T[]> extends IgxForOfDirec
16851687

16861688
public override ngOnChanges(changes: SimpleChanges) {
16871689
const forOf = 'igxGridForOf';
1688-
this.syncService.setMaster(this);
1690+
if (!this.igxGridForOfUniqueSizeCache) {
1691+
this.syncService.setMaster(this);
1692+
}
16891693
if (forOf in changes) {
16901694
const value = changes[forOf].currentValue;
16911695
if (!this._differ && value) {
@@ -1697,9 +1701,9 @@ export class IgxGridForOfDirective<T, U extends T[] = T[]> extends IgxForOfDirec
16971701
NgFor only supports binding to Iterables such as Arrays.`);
16981702
}
16991703
}
1700-
if (this.igxForScrollOrientation === 'horizontal') {
1704+
if (this.igxForScrollOrientation === 'horizontal' && !this.igxGridForOfUniqueSizeCache) {
17011705
// in case collection has changes, reset sync service
1702-
this.syncService.setMaster(this, this.igxGridForOfUniqueSizeCache);
1706+
this.syncService.setMaster(this);
17031707
}
17041708
}
17051709
const defaultItemSize = 'igxForItemSize';
@@ -1742,10 +1746,13 @@ export class IgxGridForOfDirective<T, U extends T[] = T[]> extends IgxForOfDirec
17421746
(e.g. because of filtering); if all columns are hidden, rows are
17431747
still rendered empty, so we should not reset master */
17441748
if (!this.igxForOf.length &&
1745-
this.igxForScrollOrientation === 'vertical') {
1749+
this.igxForScrollOrientation === 'vertical' &&
1750+
!this.igxGridForOfUniqueSizeCache) {
17461751
this.syncService.resetMaster();
17471752
}
1748-
this.syncService.setMaster(this);
1753+
if (!this.igxGridForOfUniqueSizeCache) {
1754+
this.syncService.setMaster(this);
1755+
}
17491756
this.igxForContainerSize = args.containerSize;
17501757
const sizeDiff = this._updateSizeCache(changes);
17511758
this._applyChanges();
@@ -1817,7 +1824,7 @@ export class IgxGridForOfDirective<T, U extends T[] = T[]> extends IgxForOfDirec
18171824
}
18181825

18191826
protected override initSizesCache(items: U): number {
1820-
if (!this.syncService.isMaster(this) && this.igxForScrollOrientation === 'horizontal') {
1827+
if (!this.igxGridForOfUniqueSizeCache && !this.syncService.isMaster(this) && this.igxForScrollOrientation === 'horizontal') {
18211828
const masterSizesCache = this.syncService.sizesCache(this.igxForScrollOrientation);
18221829
return masterSizesCache[masterSizesCache.length - 1];
18231830
}
@@ -1957,7 +1964,7 @@ export class IgxGridForOfDirective<T, U extends T[] = T[]> extends IgxForOfDirec
19571964
*/
19581965
protected override _calcMaxChunkSize(): number {
19591966
if (this.igxForScrollOrientation === 'horizontal') {
1960-
if (this.syncService.isMaster(this)) {
1967+
if (this.igxGridForOfUniqueSizeCache || this.syncService.isMaster(this)) {
19611968
return super._calcMaxChunkSize();
19621969
}
19631970
return this.syncService.chunkSize(this.igxForScrollOrientation);

projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,20 @@ describe('IgxPivotGrid #pivotGrid', () => {
366366
expect(value[1]).toBeTrue();
367367

368368
headerRow = fixture.nativeElement.querySelector('igx-pivot-header-row');
369+
370+
//Ensure for of update of cells.
371+
const headerDisplayContainers = headerRow.querySelectorAll('igx-display-container');
372+
expect(headerDisplayContainers.length).toEqual(5);
373+
expect(headerDisplayContainers[0].children.length).toEqual(1);
374+
expect(headerDisplayContainers[0].innerText).toEqual('chevron_right\nAll Countries');
375+
expect(headerDisplayContainers[1].children.length).toEqual(2);
376+
expect(headerDisplayContainers[1].innerText).toEqual('');
377+
expect(headerDisplayContainers[2].children.length).toEqual(2);
378+
expect(headerDisplayContainers[2].innerText).toEqual('');
379+
expect(headerDisplayContainers[3].children.length).toEqual(2);
380+
expect(headerDisplayContainers[3].children[0].innerText).toEqual('UnitsSold\narrow_upward');
381+
expect(headerDisplayContainers[3].children[1].innerText).toEqual('UnitPrice\narrow_upward');
382+
369383
header = headerRow.querySelector('igx-grid-header-group');
370384
expander = header.querySelectorAll('igx-icon')[0];
371385
expander.click();

0 commit comments

Comments
 (0)