Skip to content

Commit 65f2d21

Browse files
authored
Merge pull request #6095 from IgniteUI/tzhelev/fix-6005-master
Should close filter row when setting filterMode to excelStyleFilter - master
2 parents 8423d84 + 6f58c24 commit 65f2d21

File tree

4 files changed

+49
-5
lines changed

4 files changed

+49
-5
lines changed

projects/igniteui-angular/src/lib/grids/filtering/base/grid-filtering-row.component.ts

-1
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,6 @@ export class IgxGridFilteringRowComponent implements AfterViewInit {
477477

478478
this.filteringService.filteredColumn = null;
479479
this.filteringService.selectedExpression = null;
480-
this.cdr.detectChanges();
481480

482481
this.chipAreaScrollOffset = 0;
483482
this.transform(this.chipAreaScrollOffset);

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

+20-2
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,11 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
996996
*/
997997
set filterMode(value) {
998998
this._filterMode = value;
999+
1000+
if (this.filteringService.isFilterRowVisible) {
1001+
this.filteringRow.close();
1002+
}
1003+
this.notifyChanges(true);
9991004
}
10001005

10011006
/**
@@ -4345,6 +4350,17 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
43454350
return pagingHeight;
43464351
}
43474352

4353+
/**
4354+
* @hidden
4355+
*/
4356+
protected getFilterCellHeight(): number {
4357+
const headerGroupNativeEl = (this.headerGroupsList.length !== 0) ?
4358+
this.headerGroupsList[0].element.nativeElement : null;
4359+
const filterCellNativeEl = (headerGroupNativeEl) ?
4360+
headerGroupNativeEl.querySelector('igx-grid-filtering-cell') : null;
4361+
return (filterCellNativeEl) ? filterCellNativeEl.offsetHeight : 0;
4362+
}
4363+
43484364
/**
43494365
* @hidden
43504366
*/
@@ -4353,12 +4369,14 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
43534369
return null;
43544370
}
43554371

4356-
4372+
const actualTheadRow = (!this.allowFiltering || (this.allowFiltering && this.filterMode !== FilterMode.quickFilter)) ?
4373+
this.theadRow.nativeElement.offsetHeight - this.getFilterCellHeight() :
4374+
this.theadRow.nativeElement.offsetHeight;
43574375
const footerHeight = this.summariesHeight || this.tfoot.nativeElement.offsetHeight - this.tfoot.nativeElement.clientHeight;
43584376
const toolbarHeight = this.getToolbarHeight();
43594377
const pagingHeight = this.getPagingHeight();
43604378
const groupAreaHeight = this.getGroupAreaHeight();
4361-
const renderedHeight = toolbarHeight + this.theadRow.nativeElement.offsetHeight +
4379+
const renderedHeight = toolbarHeight + actualTheadRow +
43624380
footerHeight + pagingHeight + groupAreaHeight +
43634381
this.scr.nativeElement.clientHeight;
43644382

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

+29
Original file line numberDiff line numberDiff line change
@@ -3421,6 +3421,34 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
34213421
tick(100);
34223422
expect(chip.componentInstance.selected).toBeTruthy();
34233423
}));
3424+
3425+
it('Should close filterRow when changing filterMode from \'quickFilter\' to \'excelStyleFilter\'', (async () => {
3426+
GridFunctions.clickFilterCellChip(fix, 'ProductName');
3427+
fix.detectChanges();
3428+
3429+
// Add a condition chip without submitting it.
3430+
GridFunctions.typeValueInFilterRowInput('a', fix);
3431+
await wait(16);
3432+
3433+
// Change filterMode to 'excelStyleFilter`
3434+
grid.filterMode = FilterMode.excelStyleFilter;
3435+
fix.detectChanges();
3436+
3437+
// Verify the the filterRow is closed.
3438+
const filterUIRow = fix.debugElement.query(By.css(FILTER_UI_ROW));
3439+
expect(filterUIRow).toBeNull('filterRow is visible');
3440+
3441+
// Verify the ESF icons are visible.
3442+
const gridNativeElement = fix.debugElement.query(By.css('igx-grid')).nativeElement;
3443+
const thead = gridNativeElement.querySelector('.igx-grid__thead-wrapper');
3444+
const filterIcons = thead.querySelectorAll('.igx-excel-filter__icon');
3445+
expect(filterIcons.length).toEqual(4, 'incorrect esf filter icons count');
3446+
3447+
// Verify the condition was submitted.
3448+
const header = GridFunctions.getColumnHeader('ProductName', fix);
3449+
const activeFilterIcon = header.nativeElement.querySelector('.igx-excel-filter__icon--filtered');
3450+
expect(activeFilterIcon).toBeDefined('no active filter icon was found');
3451+
}));
34243452
});
34253453
describe(null, () => {
34263454
let fix, grid;
@@ -3629,6 +3657,7 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
36293657
let fix, grid;
36303658
beforeEach(fakeAsync(() => {
36313659
fix = TestBed.createComponent(IgxGridFilteringComponent);
3660+
fix.detectChanges();
36323661
grid = fix.componentInstance.grid;
36333662
grid.filterMode = FilterMode.excelStyleFilter;
36343663
fix.detectChanges();

src/app/grid-filtering/grid-filtering.sample.ts

-2
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,6 @@ export class GridFilteringComponent implements OnInit, AfterViewInit {
534534
const filterMode = this.filterModes[event.index].value as FilterMode;
535535
if (filterMode !== this.grid1.filterMode) {
536536
this.grid1.filterMode = filterMode;
537-
this.grid1.reflow();
538537
}
539538
}
540539

@@ -552,6 +551,5 @@ export class GridFilteringComponent implements OnInit, AfterViewInit {
552551

553552
public onAllowFilteringChanged(event: IChangeCheckboxEventArgs) {
554553
this.grid1.allowFiltering = event.checked;
555-
this.grid1.reflow();
556554
}
557555
}

0 commit comments

Comments
 (0)