Skip to content

Commit 9caa9b2

Browse files
Fixed header height issue for grouped headers (#15001)
1 parent eca1c18 commit 9caa9b2

File tree

5 files changed

+15
-34
lines changed

5 files changed

+15
-34
lines changed

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

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,9 +2270,6 @@ export abstract class IgxGridBaseDirective implements GridType,
22702270
this._allowFiltering = value;
22712271
this.filteringService.registerSVGIcons();
22722272

2273-
if (!this._init) {
2274-
this.calcGridHeadRow();
2275-
}
22762273

22772274
this.filteringService.isFilterRowVisible = false;
22782275
this.filteringService.filteredColumn = null;
@@ -6840,25 +6837,11 @@ export abstract class IgxGridBaseDirective implements GridType,
68406837
}
68416838
}
68426839

6843-
/**
6844-
* @hidden
6845-
* @internal
6846-
*/
6847-
protected calcGridHeadRow() {
6848-
if (this.maxLevelHeaderDepth) {
6849-
this._baseFontSize = parseFloat(getComputedStyle(this.document.documentElement).getPropertyValue('font-size'));
6850-
const hasFilterRow = this._allowFiltering && this._filterMode === FilterMode.quickFilter;
6851-
const minSize = (this.maxLevelHeaderDepth + 1 + (hasFilterRow ? 1 : 0)) * this.defaultRowHeight / this._baseFontSize;
6852-
this.theadRow.nativeElement.style.minHeight = `${minSize}rem`;
6853-
}
6854-
}
6855-
68566840
/**
68576841
* @hidden
68586842
* Sets TBODY height i.e. this.calcHeight
68596843
*/
68606844
protected calculateGridHeight() {
6861-
this.calcGridHeadRow();
68626845

68636846
this.calcHeight = this._calculateGridBodyHeight();
68646847
if (this.pinnedRowHeight && this.calcHeight) {
@@ -7786,7 +7769,7 @@ export abstract class IgxGridBaseDirective implements GridType,
77867769
} else {
77877770
this._shouldRecalcRowHeight = true;
77887771
}
7789-
}
7772+
}
77907773
}
77917774

77927775
// TODO: About to Move to CRUD

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,19 @@ describe('IgxGrid - multi-column headers #grid', () => {
6767
expect(grid.getColumnByName('ContactName').level).toEqual(expectedLevel);
6868
});
6969

70+
it('should initialize a grid with correct header height', () => {
71+
fixture = TestBed.createComponent(ColumnGroupTestComponent);
72+
fixture.detectChanges();
73+
grid = fixture.componentInstance.grid;
74+
75+
const expectedGridHeaderHeight = 151;
76+
const headerHeight = grid.nativeElement
77+
.querySelector("igx-grid-header-row")
78+
.getBoundingClientRect().height;
79+
80+
expect(Math.round(headerHeight)).toEqual(expectedGridHeaderHeight);
81+
});
82+
7083
it('Should render column group headers correctly.', fakeAsync(() => {
7184
fixture = TestBed.createComponent(BlueWhaleGridComponent);
7285
fixture.detectChanges();

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2746,6 +2746,7 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
27462746

27472747
GridFunctions.clickFilterCellChip(fix, 'AnotherField');
27482748
fix.detectChanges();
2749+
grid.cdr.detectChanges();
27492750

27502751
// check if it is positioned at the bottom of the thead.
27512752
const theadWrapper = grid.theadRow.nativeElement.firstElementChild;

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,6 @@ export class IgxGridHeaderComponent implements DoCheck, OnDestroy {
109109
return this.selected;
110110
}
111111

112-
@HostBinding('style.height.rem')
113-
public get height() {
114-
if (!this.grid.hasColumnGroups || this.grid.type === 'pivot') {
115-
return null;
116-
}
117-
118-
return (this.grid.maxLevelHeaderDepth + 1 - this.column.level) * this.grid.defaultRowHeight / this.grid._baseFontSize;
119-
}
120-
121112
/**
122113
* @hidden
123114
*/

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,13 +2106,6 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
21062106
}
21072107
}
21082108

2109-
/**
2110-
* @hidden
2111-
* @internal
2112-
*/
2113-
protected override calcGridHeadRow() {
2114-
}
2115-
21162109
protected override buildDataView(data: any[]) {
21172110
this._dataView = data;
21182111
}

0 commit comments

Comments
 (0)