Skip to content

Commit b10fc2c

Browse files
authored
fix(grid): keep conditionName in sync on condition changed callback [21.0.x] (#16925)
* fix(grid): keep conditionName in sync on condition changed callback * test(grid): add conditionName sync coverage for Excel-style custom filter dialog
1 parent 24f24c9 commit b10fc2c

3 files changed

Lines changed: 38 additions & 0 deletions

File tree

projects/igniteui-angular/grids/core/src/filtering/base/grid-filtering-row.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,7 @@ export class IgxGridFilteringRowComponent implements OnInit, AfterViewInit, OnDe
611611
public onConditionsChanged(eventArgs) {
612612
const value = (eventArgs.newSelection as IgxDropDownItemComponent).value;
613613
this.expression.condition = this.getCondition(value);
614+
this.expression.conditionName = value;
614615
if (this.expression.condition.isUnary) {
615616
// update grid's filtering on the next cycle to ensure the drop-down is closed
616617
// if the drop-down is not closed this event handler will be invoked multiple times

projects/igniteui-angular/grids/core/src/filtering/excel-style/excel-style-default-expression.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ export class IgxExcelStyleDefaultExpressionComponent implements AfterViewInit {
133133
public onConditionsChanged(eventArgs: any) {
134134
const value = (eventArgs.newSelection as IgxSelectComponent).value;
135135
this.expressionUI.expression.condition = this.getCondition(value);
136+
this.expressionUI.expression.conditionName = value;
136137

137138
this.focus();
138139
}

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
132132
tick();
133133
fix.detectChanges();
134134

135+
let operands =
136+
(grid.filteringExpressionsTree.filteringOperands[0] as IFilteringExpressionsTree)
137+
.filteringOperands as IFilteringExpression[];
138+
verifyFilteringExpression(operands[0], 'ProductName', 'startsWith', 'Net');
135139
verifyFilterUIPosition(filterUIRow, grid);
136140
verifyFilterRowUI(input, close, reset, false);
137141
expect(grid.rowList.length).toEqual(1);
@@ -143,6 +147,11 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
143147
tick();
144148
fix.detectChanges();
145149

150+
operands =
151+
(grid.filteringExpressionsTree.filteringOperands[0] as IFilteringExpressionsTree)
152+
.filteringOperands as IFilteringExpression[];
153+
verifyFilteringExpression(operands[0], 'ProductName', 'endsWith', 'script');
154+
146155
expect(grid.rowList.length).toEqual(2);
147156
verifyFilterRowUI(input, close, reset, false);
148157

@@ -3824,6 +3833,33 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
38243833
expect(filterIcon).toBeDefined();
38253834
}));
38263835

3836+
it('Should keep conditionName in sync when changing condition in ESF custom dialog.', fakeAsync(() => {
3837+
GridFunctions.clickExcelFilterIconFromCode(fix, grid, 'ProductName');
3838+
3839+
GridFunctions.clickExcelFilterCascadeButton(fix);
3840+
tick();
3841+
fix.detectChanges();
3842+
3843+
// Open custom dialog with 'contains' condition (index 0 in cascade menu for string column)
3844+
GridFunctions.clickOperatorFromCascadeMenu(fix, 0);
3845+
tick(100);
3846+
3847+
// set first expression's value
3848+
GridFunctions.setInputValueESF(fix, 0, 'Net');
3849+
tick(100);
3850+
3851+
// change first expression's operator from 'contains' to 'startsWith' (index 2 for string column)
3852+
GridFunctions.setOperatorESF(fix, 0, 2);
3853+
tick(100);
3854+
3855+
GridFunctions.clickApplyExcelStyleCustomFiltering(fix);
3856+
3857+
const operands =
3858+
(grid.filteringExpressionsTree.filteringOperands[0] as IFilteringExpressionsTree)
3859+
.filteringOperands as IFilteringExpression[];
3860+
verifyFilteringExpression(operands[0], 'ProductName', 'startsWith', 'Net');
3861+
}));
3862+
38273863
it('Should filter grid via custom dialog.', fakeAsync(() => {
38283864
GridFunctions.clickExcelFilterIconFromCode(fix, grid, 'Downloads');
38293865

0 commit comments

Comments
 (0)