Skip to content

fix(esf): add empty filter if no filter is applied - 12.2.x #10273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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