Skip to content

Commit 064a439

Browse files
authored
Merge pull request #8405 from IgniteUI/ibarakov/fix-8371-master
fix(esf): clear search criteria after closing esf menu with templates
2 parents 59d43b3 + 2386734 commit 064a439

File tree

2 files changed

+63
-2
lines changed

2 files changed

+63
-2
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ export class IgxExcelStyleSearchComponent implements AfterViewInit, OnDestroy {
152152
});
153153

154154
esf.listDataLoaded.pipe(takeUntil(this.destroy$)).subscribe(() => {
155-
this.filterListData();
155+
this.searchValue ?
156+
this.clearInput() :
157+
this.filterListData();
156158
});
157159
}
158160

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

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4651,7 +4651,49 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
46514651
expect(excelMenu).not.toBeNull();
46524652
expect(inputNativeElement.value).toBe('', 'input isn\'t cleared correctly');
46534653
}));
4654-
});
4654+
4655+
it('Should clear search criteria when selecting clear column filters option.', fakeAsync(() => {
4656+
GridFunctions.clickExcelFilterIconFromCode(fix, grid, 'ProductName');
4657+
4658+
let checkboxes = GridFunctions.getExcelStyleFilteringCheckboxes(fix);
4659+
fix.detectChanges();
4660+
4661+
checkboxes[0].click();
4662+
tick();
4663+
fix.detectChanges();
4664+
4665+
checkboxes[2].click();
4666+
tick();
4667+
fix.detectChanges();
4668+
4669+
GridFunctions.clickApplyExcelStyleFiltering(fix);
4670+
tick();
4671+
fix.detectChanges();
4672+
expect(grid.filteredData.length).toEqual(1);
4673+
4674+
GridFunctions.clickExcelFilterIconFromCode(fix, grid, 'ProductName');
4675+
flush();
4676+
4677+
let inputNativeElement = GridFunctions.getExcelStyleSearchComponentInput(fix);
4678+
UIInteractions.clickAndSendInputElementValue(inputNativeElement, 'Net', fix);
4679+
4680+
const listItems = GridFunctions.getExcelStyleSearchComponentListItems(fix);
4681+
expect(listItems.length).toBe(3, 'incorrect rendered list items count');
4682+
4683+
GridFunctions.clickClearFilterInExcelStyleFiltering(fix);
4684+
flush();
4685+
expect(grid.filteredData).toBeNull();
4686+
4687+
inputNativeElement = GridFunctions.getExcelStyleSearchComponentInput(fix);
4688+
expect(inputNativeElement.value).toBe('', 'search criteria is not cleared');
4689+
4690+
checkboxes = GridFunctions.getExcelStyleFilteringCheckboxes(fix);
4691+
const listItemsCheckboxes = checkboxes.slice(1, checkboxes.length);
4692+
for (const checkbox of listItemsCheckboxes) {
4693+
ControlsFunction.verifyCheckboxState(checkbox.parentElement);
4694+
}
4695+
}));
4696+
});
46554697

46564698
describe('Templates: ', () => {
46574699
let fix, grid;
@@ -4801,6 +4843,23 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
48014843
GridSelectionFunctions.verifyColumnAndCellsSelected(columnId, false);
48024844

48034845
});
4846+
4847+
it('Should reset esf menu with templates on column change', fakeAsync(() => {
4848+
GridFunctions.clickExcelFilterIconFromCode(fix, grid, 'Downloads');
4849+
flush();
4850+
4851+
let inputNativeElement = GridFunctions.getExcelStyleSearchComponentInput(fix);
4852+
UIInteractions.clickAndSendInputElementValue(inputNativeElement, 20, fix);
4853+
4854+
const listItems = GridFunctions.getExcelStyleSearchComponentListItems(fix);
4855+
expect(listItems.length).toBe(3, 'incorrect rendered list items count');
4856+
4857+
GridFunctions.clickExcelFilterIconFromCode(fix, grid, 'ProductName');
4858+
flush();
4859+
4860+
inputNativeElement = GridFunctions.getExcelStyleSearchComponentInput(fix);
4861+
expect(inputNativeElement.value).toBe('', 'input value didn\'t reset');
4862+
}));
48044863
});
48054864

48064865
describe('Load values on demand', () => {

0 commit comments

Comments
 (0)