Skip to content

Commit dd1c96e

Browse files
authored
Merge branch '15.1.x' into ibarakov/feat-13524-15.1.x
2 parents 13276b0 + f737f89 commit dd1c96e

File tree

3 files changed

+52
-4
lines changed

3 files changed

+52
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7382,13 +7382,13 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
73827382
}
73837383
const cells = this._dataRowList.map(x => x.cells.find(c => c.column === col));
73847384
cells.forEach((cell) => cellsContentWidths.push(cell?.nativeElement?.offsetWidth || 0));
7385+
const header = this.headerCellList.find(x => x.column === col);
7386+
cellsContentWidths.push(header.nativeElement.offsetWidth);
73857387
const max = Math.max(...cellsContentWidths);
73867388
if (max === 0) {
73877389
// cells not in DOM yet...
73887390
continue;
73897391
}
7390-
const header = this.headerCellList.find(x => x.column === col);
7391-
cellsContentWidths.push(header.nativeElement.offsetWidth);
73927392
let maxSize = Math.ceil(Math.max(...cellsContentWidths)) + 1;
73937393
if (col.maxWidth && maxSize > col.maxWidthPx) {
73947394
maxSize = col.maxWidthPx;

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

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,8 @@ describe('IgxGrid Component Tests #grid', () => {
804804
IgxGridColumnPercentageWidthComponent,
805805
IgxGridWrappedInContComponent,
806806
IgxGridFormattingComponent,
807-
IgxGridFixedContainerHeightComponent
807+
IgxGridFixedContainerHeightComponent,
808+
IgxGridColumnHeaderAutoSizeComponent
808809
],
809810
imports: [
810811
NoopAnimationsModule, IgxGridModule]
@@ -1865,6 +1866,23 @@ describe('IgxGrid Component Tests #grid', () => {
18651866

18661867
expect(grid.columnList.get(0).width).toBe('50%');
18671868
});
1869+
1870+
it('should correctly autosize column headers when the grid container has no data and is initially hidden and then shown', async () => {
1871+
const fix = TestBed.createComponent(IgxGridColumnHeaderAutoSizeComponent);
1872+
const grid = fix.componentInstance.grid;
1873+
1874+
//waiting for reqeustAnimationFrame to finish
1875+
await wait(17);
1876+
fix.detectChanges();
1877+
1878+
fix.componentInstance.gridContainerHidden = false;
1879+
await wait(17)
1880+
fix.detectChanges()
1881+
1882+
const calcWidth = parseInt(grid.columnList.first.calcWidth, 10)
1883+
1884+
expect(calcWidth).not.toBe(80);
1885+
});
18681886
});
18691887

18701888
describe('IgxGrid - API methods', () => {
@@ -2880,6 +2898,36 @@ export class IgxGridDefaultRenderingComponent {
28802898
}
28812899
}
28822900

2901+
@Component({
2902+
template: `
2903+
<div [hidden]="gridContainerHidden">
2904+
<igx-grid #grid>
2905+
<igx-column
2906+
field="field1"
2907+
header="Field 1 Header"
2908+
width="auto"
2909+
></igx-column>
2910+
<igx-column
2911+
field="field2"
2912+
header="Field 2 Header"
2913+
width="auto"
2914+
></igx-column>
2915+
<igx-column
2916+
field="field3"
2917+
header="Field 3 Header"
2918+
width="auto"
2919+
></igx-column>
2920+
</igx-grid>
2921+
</div>`,
2922+
})
2923+
export class IgxGridColumnHeaderAutoSizeComponent {
2924+
@ViewChild('grid', { read: IgxGridComponent, static: true })
2925+
public grid: IgxGridComponent;
2926+
2927+
public gridContainerHidden = true;
2928+
2929+
}
2930+
28832931
@Component({
28842932
template: `<igx-grid #grid [data]="data" [width]="'500px'" (columnInit)="initColumns($event)">
28852933
<igx-column *ngFor="let col of columns" [field]="col.key" [header]="col.key" [dataType]="col.dataType">

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-row-dimension-content.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export class IgxPivotRowDimensionContentComponent extends IgxGridHeaderRowCompon
146146

147147
protected extractFromDimension(dim: IPivotDimension, rowData: IPivotGridGroupRecord) {
148148
const field = dim.memberName;
149-
const header = rowData.dimensionValues.get(field);
149+
const header = rowData?.dimensionValues.get(field);
150150
const col = this._createColComponent(field, header, dim);
151151
return col;
152152
}

0 commit comments

Comments
 (0)