Skip to content

Commit 5d05d80

Browse files
Svetoslav KrastevSvetoslav Krastev
authored andcommitted
fix(grid): Fix filtering row not included correctly into header row size calculation.
1 parent d6da331 commit 5d05d80

File tree

5 files changed

+39
-7
lines changed

5 files changed

+39
-7
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ import { IgxGridValidationService } from './grid/grid-validation.service';
177177
let FAKE_ROW_ID = -1;
178178
const DEFAULT_ITEMS_PER_PAGE = 15;
179179
const MINIMUM_COLUMN_WIDTH = 136;
180-
const FILTER_ROW_HEIGHT = 50;
181180
// By default row editing overlay outlet is inside grid body so that overlay is hidden below grid header when scrolling.
182181
// In cases when grid has 1-2 rows there isn't enough space in grid body and row editing overlay should be shown above header.
183182
// Default row editing overlay height is higher then row height that is why the case is valid also for row with 2 rows.
@@ -6926,10 +6925,8 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
69266925
protected calcGridHeadRow() {
69276926
if (this.maxLevelHeaderDepth) {
69286927
this._baseFontSize = parseFloat(getComputedStyle(this.document.documentElement).getPropertyValue('font-size'));
6929-
let minSize = (this.maxLevelHeaderDepth + 1) * this.defaultRowHeight / this._baseFontSize;
6930-
if (this._allowFiltering && this._filterMode === FilterMode.quickFilter) {
6931-
minSize += (FILTER_ROW_HEIGHT + 1) / this._baseFontSize;
6932-
}
6928+
const hasFilterRow = this._allowFiltering && this._filterMode === FilterMode.quickFilter;
6929+
const minSize = (this.maxLevelHeaderDepth + 1 + (hasFilterRow ? 1 : 0)) * this.defaultRowHeight / this._baseFontSize;
69336930
this.theadRow.nativeElement.style.minHeight = `${minSize}rem`;
69346931
}
69356932
}

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2541,6 +2541,23 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
25412541
}));
25422542

25432543
// Filtering + Column Groups
2544+
it('should size correctly the header based on display density.', () => {
2545+
grid.displayDensity = "comfortable";
2546+
fix.detectChanges();
2547+
2548+
const thead = GridFunctions.getGridHeader(grid).nativeElement;
2549+
expect(thead.getBoundingClientRect().height).toEqual(grid.defaultRowHeight * 4 + 1);
2550+
2551+
grid.displayDensity = "cosy";
2552+
fix.detectChanges();
2553+
expect(thead.getBoundingClientRect().height).toEqual(grid.defaultRowHeight * 4 + 1);
2554+
2555+
grid.displayDensity = "compact";
2556+
fix.detectChanges();
2557+
expect(thead.getBoundingClientRect().height).toEqual(grid.defaultRowHeight * 4 + 1);
2558+
2559+
});
2560+
25442561
it('should position filter row correctly when grid has column groups.', fakeAsync(() => {
25452562
const thead = GridFunctions.getGridHeader(grid).nativeElement;
25462563

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.density-chooser {
2+
margin-bottom: 16px;
3+
min-width: 900px;
4+
}

src/app/grid-column-groups/grid-column-groups.sample.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
<section class="sample-content">
2+
<div class="density-chooser">
3+
<igx-buttongroup [values]="displayDensities" (selected)="selectDensity($event)"></igx-buttongroup>
4+
</div>
25
<ng-template igxCollapsibleIndicator let-column="column" #ind >
36
<igx-icon [attr.draggable]="false">{{column.expanded ? 'remove' : 'add'}} </igx-icon>
47
</ng-template>
5-
<igx-grid [allowFiltering]="true" [moving]="true" [pinning]="pinningConfig" [rowSelection]="selectionMode" #grid [data]="data" displayDensity="compact">
8+
<igx-grid [displayDensity]="density" [allowFiltering]="true" [moving]="true" [pinning]="pinningConfig" [rowSelection]="selectionMode" #grid [data]="data" displayDensity="compact">
69
<igx-grid-toolbar [displayDensity]="grid.displayDensity">
710
<igx-grid-toolbar-actions>
811
<igx-grid-toolbar-pinning></igx-grid-toolbar-pinning>

src/app/grid-column-groups/grid-column-groups.sample.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component, ViewChild } from '@angular/core';
2-
import { IgxGridComponent, IgxColumnGroupComponent, GridSelectionMode, ColumnPinningPosition } from 'igniteui-angular';
2+
import { IgxGridComponent, IgxColumnGroupComponent, GridSelectionMode, ColumnPinningPosition, DisplayDensity } from 'igniteui-angular';
33

44
@Component({
55
selector: 'app-grid-column-groups-sample',
@@ -47,12 +47,19 @@ export class GridColumnGroupsSampleComponent {
4747
];
4848
/* eslint-enable max-len */
4949

50+
public density: string = DisplayDensity.compact;
51+
public displayDensities;
5052

5153
constructor() {
5254
for (const item of this.data) {
5355
item.FullAddress = `${item.Address}, ${item.City}, ${item.Country}`;
5456
}
5557
this.selectionMode = GridSelectionMode.none;
58+
this.displayDensities = [
59+
{ label: 'comfortable', selected: this.density === 'comfortable', togglable: true },
60+
{ label: 'cosy', selected: this.density === 'cosy', togglable: true },
61+
{ label: 'compact', selected: this.density === 'compact', togglable: true }
62+
];
5663
}
5764

5865
public pinGroup() {
@@ -96,4 +103,8 @@ export class GridColumnGroupsSampleComponent {
96103

97104
this.columnGroupStates.set(columnGroup, !this.columnGroupStates.get(columnGroup));
98105
}
106+
107+
public selectDensity(event) {
108+
this.density = this.displayDensities[event.index].label;
109+
}
99110
}

0 commit comments

Comments
 (0)