Skip to content

Commit 2c89ffa

Browse files
committed
fix(esf): clear search criteria when selecting "Clear column filters" option
1 parent f1e8a80 commit 2c89ffa

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

projects/igniteui-angular/src/lib/grids/filtering/excel-style/excel-style-search.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ export class IgxExcelStyleSearchComponent implements AfterViewInit, OnDestroy {
129129
esf.columnChange.pipe(takeUntil(this.destroy$)).subscribe(() => {
130130
this.virtDir.resetScrollPosition();
131131
});
132+
133+
esf.listDataLoaded.pipe(takeUntil(this.destroy$)).subscribe(() => {
134+
this.clearInput();
135+
});
132136
}
133137

134138
public ngAfterViewInit() {

projects/igniteui-angular/src/lib/grids/filtering/excel-style/grid.excel-style-filtering.component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,12 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy {
284284
@Output()
285285
public columnChange = new EventEmitter<IgxColumnComponent>();
286286

287+
/**
288+
* @hidden @internal
289+
*/
290+
@Output()
291+
public listDataLoaded = new EventEmitter();
292+
287293
/**
288294
* @hidden @internal
289295
*/
@@ -549,6 +555,8 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy {
549555
if (!(this.cdr as any).destroyed) {
550556
this.cdr.detectChanges();
551557
}
558+
559+
this.listDataLoaded.emit();
552560
}
553561

554562
private getColumnFilterExpressionsTree() {

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

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4377,6 +4377,49 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
43774377
expect(listItems[3].innerText).toBe('custoM', 'incorrect list item label');
43784378
expect(listItems[4].innerText).toBe('custom', 'incorrect list item label');
43794379
}));
4380+
4381+
it('Should clear search criteria when selecting clear column filters option.', fakeAsync(() => {
4382+
GridFunctions.clickExcelFilterIconFromCode(fix, grid, 'ProductName');
4383+
4384+
let checkboxes: any = Array.from(GridFunctions.getExcelStyleFilteringCheckboxes(fix));
4385+
4386+
tick(100);
4387+
fix.detectChanges();
4388+
4389+
checkboxes[0].click();
4390+
tick();
4391+
fix.detectChanges();
4392+
4393+
checkboxes[2].click();
4394+
tick();
4395+
fix.detectChanges();
4396+
4397+
GridFunctions.clickApplyExcelStyleFiltering(fix);
4398+
tick(100);
4399+
fix.detectChanges();
4400+
4401+
expect(grid.filteredData.length).toEqual(1);
4402+
4403+
GridFunctions.clickExcelFilterIconFromCode(fix, grid, 'ProductName');
4404+
4405+
let inputNativeElement = GridFunctions.getExcelStyleSearchComponentInput(fix);
4406+
UIInteractions.clickAndSendInputElementValue(inputNativeElement, 'Net', fix);
4407+
4408+
const listItems = GridFunctions.getExcelStyleSearchComponentListItems(fix);
4409+
expect(listItems.length).toBe(2, 'incorrect rendered list items count');
4410+
4411+
GridFunctions.clickClearFilterInExcelStyleFiltering(fix);
4412+
fix.detectChanges();
4413+
flush();
4414+
4415+
expect(grid.filteredData).toBeNull();
4416+
4417+
inputNativeElement = GridFunctions.getExcelStyleSearchComponentInput(fix);
4418+
expect(inputNativeElement.value).toBe('', 'search criteria is not cleared');
4419+
4420+
checkboxes = Array.from(GridFunctions.getExcelStyleFilteringCheckboxes(fix));
4421+
expect(checkboxes.every(ch => ch.checked)).toBeTrue();
4422+
}));
43804423
});
43814424

43824425
describe('Templates: ', () => {
@@ -4729,7 +4772,6 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
47294772
GridSelectionFunctions.verifyColumnAndCellsSelected(columnId, false);
47304773

47314774
});
4732-
47334775
});
47344776
});
47354777

0 commit comments

Comments
 (0)