Skip to content

Commit

Permalink
Merge pull request #10237 from IgniteUI/dmdimitrov/fix-10005-master
Browse files Browse the repository at this point in the history
fix(esf): add empty filter if no filter is applied - master
  • Loading branch information
kdinev authored Oct 12, 2021
2 parents 672ae89 + ffef918 commit 97ecddd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,10 @@ export class IgxFilteringService implements OnDestroy {
}
}

const emptyFilter = new FilteringExpressionsTree(null, field);
const onFilteringEventArgs: IFilteringEventArgs = {
owner: this.grid,
filteringExpressions: null,
filteringExpressions: emptyFilter,
cancel: false };

this.grid.filtering.emit(onFilteringEventArgs);
Expand All @@ -292,7 +293,7 @@ export class IgxFilteringService implements OnDestroy {
this.clear_filter(field);

// Wait for the change detection to update filtered data through the pipes and then emit the event.
requestAnimationFrame(() => this.grid.filteringDone.emit(null));
requestAnimationFrame(() => this.grid.filteringDone.emit(emptyFilter));

if (field) {
const expressions = this.getExpressions(field);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,10 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
GridFunctions.clickFilterCellChip(fix, columnName);
GridFunctions.resetFilterRow(fix);

expect(grid.filtering.emit).toHaveBeenCalledWith({ owner: grid, cancel: false, filteringExpressions: null });
const emptyFilter = new FilteringExpressionsTree(null, columnName);
expect(grid.filtering.emit).toHaveBeenCalledWith({ owner: grid, cancel: false, filteringExpressions: emptyFilter });
expect(grid.filtering.emit).toHaveBeenCalledTimes(2);
expect(grid.filteringDone.emit).toHaveBeenCalledWith(null);
expect(grid.filteringDone.emit).toHaveBeenCalledWith(emptyFilter);
expect(grid.filteringDone.emit).toHaveBeenCalledTimes(2);

const filterUiRow = fix.debugElement.query(By.css(FILTER_UI_ROW));
Expand All @@ -512,9 +513,10 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
tick(100);
fix.detectChanges();

const args = { owner: grid, cancel: false, filteringExpressions: null };
const emptyFilter = new FilteringExpressionsTree(null, columnName);
const args = { owner: grid, cancel: false, filteringExpressions: emptyFilter };
expect(grid.filtering.emit).toHaveBeenCalledWith(args);
expect(grid.filteringDone.emit).toHaveBeenCalledWith(null);
expect(grid.filteringDone.emit).toHaveBeenCalledWith(emptyFilter);
}));

it('Removing second condition removes the And/Or button', fakeAsync(() => {
Expand Down Expand Up @@ -826,13 +828,14 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
spyOn(grid.filtering, 'emit');
spyOn(grid.filteringDone, 'emit');

grid.filter('ProductName', 'I', IgxStringFilteringOperand.instance().condition('startsWith'));
const columnName = 'ProductName';
grid.filter(columnName, 'I', IgxStringFilteringOperand.instance().condition('startsWith'));
tick(30);
fix.detectChanges();

expect(grid.rowList.length).toEqual(2);

const filteringExpressions = grid.filteringExpressionsTree.find('ProductName') as FilteringExpressionsTree;
const filteringExpressions = grid.filteringExpressionsTree.find(columnName) as FilteringExpressionsTree;
const args = { owner: grid, cancel: false, filteringExpressions };
expect(grid.filtering.emit).toHaveBeenCalledWith(args);
expect(grid.filtering.emit).toHaveBeenCalledTimes(1);
Expand All @@ -849,10 +852,11 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {

expect(grid.rowList.length).toEqual(8);

args.filteringExpressions = null;
const emptyFilter = new FilteringExpressionsTree(null, columnName);
args.filteringExpressions = emptyFilter;
expect(grid.filtering.emit).toHaveBeenCalledWith(args);
expect(grid.filtering.emit).toHaveBeenCalledTimes(2);
expect(grid.filteringDone.emit).toHaveBeenCalledWith(null);
expect(grid.filteringDone.emit).toHaveBeenCalledWith(emptyFilter);
expect(grid.filteringDone.emit).toHaveBeenCalledTimes(2);
}));

Expand Down

0 comments on commit 97ecddd

Please sign in to comment.