Skip to content

Commit ce85d5e

Browse files
authored
fix(grid): always emit event with args #8614 (#8753)
1 parent b7cbcfd commit ce85d5e

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,9 @@ export class IgxFilteringService implements OnDestroy {
216216
this.gridAPI.filter(field, value, expressionForColumn.condition, filteringIgnoreCase);
217217
}
218218
}
219-
219+
const eventArgs = this.grid.filteringExpressionsTree.find(field) as FilteringExpressionsTree;
220220
// Wait for the change detection to update filtered data through the pipes and then emit the event.
221-
requestAnimationFrame(() => this.grid.onFilteringDone.emit(col.filteringExpressionsTree));
221+
requestAnimationFrame(() => this.grid.onFilteringDone.emit(eventArgs));
222222
}
223223

224224
/**

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,17 @@ describe('IgxGrid - Filtering actions #grid', () => {
905905
expect(grid.rowList.length).toEqual(2);
906906
}));
907907

908+
it('Should always emit onFilteringDone with proper eventArgs, even when column does not exist', fakeAsync(() => {
909+
spyOn(grid.onFilteringDone, 'emit');
910+
grid.filteringLogic = FilteringLogic.Or;
911+
grid.filter('Nonexisting', 'ignite', IgxStringFilteringOperand.instance().condition('contains'), true);
912+
tick(100);
913+
fix.detectChanges();
914+
expect(grid.rowList.length).toEqual(0);
915+
const args = grid.filteringExpressionsTree.find('Nonexisting') as FilteringExpressionsTree;
916+
expect(grid.onFilteringDone.emit).toHaveBeenCalledWith(args);
917+
}));
918+
908919
it('Should emit onFilteringDone when filtering globally', fakeAsync(() => {
909920
spyOn(grid.onFilteringDone, 'emit');
910921

0 commit comments

Comments
 (0)