Skip to content

Commit 3556c57

Browse files
committed
fix(grid): call condition logic only if exists
1 parent 198d060 commit 3556c57

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

projects/igniteui-angular/src/lib/data-operations/filtering-strategy.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,22 @@ describe('Unit testing FilteringStrategy', () => {
4949
const res = fs.matchRecord(rec, expressionTree);
5050
expect(res).toBeTruthy();
5151
});
52+
53+
it ('tests `findMatchByExpression` for working with filtering operands with missing condition', () => {
54+
const rec = data[0];
55+
const expressionTree = new FilteringExpressionsTree(FilteringLogic.Or);
56+
expressionTree.filteringOperands = [
57+
{
58+
conditionName: 'contains',
59+
fieldName: 'string',
60+
ignoreCase: false,
61+
searchVal: 'ROW'
62+
}
63+
];
64+
const res = fs.matchRecord(rec, expressionTree);
65+
expect(res).toBeFalsy();
66+
});
67+
5268
it ('tests `findMatch`', () => {
5369
const rec = data[0];
5470
const res = fs.findMatchByExpression(rec, {

projects/igniteui-angular/src/lib/data-operations/filtering-strategy.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ export interface IgxFilterItem {
3939
export abstract class BaseFilteringStrategy implements IFilteringStrategy {
4040
// protected
4141
public findMatchByExpression(rec: any, expr: IFilteringExpression, isDate?: boolean, isTime?: boolean, grid?: GridType): boolean {
42-
const cond = expr.condition;
4342
const val = this.getFieldValue(rec, expr.fieldName, isDate, isTime, grid);
44-
return cond.logic(val, expr.searchVal, expr.ignoreCase);
43+
return expr.condition?.logic(val, expr.searchVal, expr.ignoreCase);
4544
}
4645

4746
// protected

0 commit comments

Comments
 (0)