Skip to content

Commit a638390

Browse files
hanastasovCopilot
andauthored
fix(grid): keep conditionName in sync on condition changed callback [20.1.x] (#16924)
* fix(grid): keep conditionName in sync on condition changed callback * test(grid): add conditionName sync coverage for Excel-style custom filter dialog (#16933) * Initial plan * test(grid): add conditionName sync test for ESF custom filter dialog Co-authored-by: hanastasov <14248932+hanastasov@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: hanastasov <14248932+hanastasov@users.noreply.github.com> --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: hanastasov <14248932+hanastasov@users.noreply.github.com>
1 parent 7446cf9 commit a638390

3 files changed

Lines changed: 38 additions & 0 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ export class IgxGridFilteringRowComponent implements AfterViewInit, OnDestroy {
584584
public onConditionsChanged(eventArgs) {
585585
const value = (eventArgs.newSelection as IgxDropDownItemComponent).value;
586586
this.expression.condition = this.getCondition(value);
587+
this.expression.conditionName = value;
587588
if (this.expression.condition.isUnary) {
588589
// update grid's filtering on the next cycle to ensure the drop-down is closed
589590
// if the drop-down is not closed this event handler will be invoked multiple times

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ export class IgxExcelStyleDefaultExpressionComponent implements AfterViewInit {
152152
public onConditionsChanged(eventArgs: any) {
153153
const value = (eventArgs.newSelection as IgxSelectComponent).value;
154154
this.expressionUI.expression.condition = this.getCondition(value);
155+
this.expressionUI.expression.conditionName = value;
155156

156157
this.focus();
157158
}

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

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

150+
let operands =
151+
(grid.filteringExpressionsTree.filteringOperands[0] as IFilteringExpressionsTree)
152+
.filteringOperands as IFilteringExpression[];
153+
verifyFilteringExpression(operands[0], 'ProductName', 'startsWith', 'Net');
150154
verifyFilterUIPosition(filterUIRow, grid);
151155
verifyFilterRowUI(input, close, reset, false);
152156
expect(grid.rowList.length).toEqual(1);
@@ -156,6 +160,10 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
156160
GridFunctions.openFilterDDAndSelectCondition(fix, 3);
157161
GridFunctions.typeValueInFilterRowInput('script', fix, input);
158162

163+
operands =
164+
(grid.filteringExpressionsTree.filteringOperands[0] as IFilteringExpressionsTree)
165+
.filteringOperands as IFilteringExpression[];
166+
verifyFilteringExpression(operands[0], 'ProductName', 'endsWith', 'script');
159167
expect(grid.rowList.length).toEqual(2);
160168
verifyFilterRowUI(input, close, reset, false);
161169

@@ -3831,6 +3839,33 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
38313839
expect(grid.filteredData.length).toEqual(1);
38323840
}));
38333841

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

@@ -7519,6 +7554,7 @@ const verifyGridSubmenuSize = (gridNativeElement: HTMLElement, expectedSize: Siz
75197554
const verifyFilteringExpression = (operand: IFilteringExpression, fieldName: string, conditionName: string, searchVal: any) => {
75207555
expect(operand.fieldName).toBe(fieldName);
75217556
expect(operand.condition.name).toBe(conditionName);
7557+
expect(operand.conditionName).toBe(conditionName);
75227558
expect(operand.searchVal).toEqual(searchVal);
75237559
};
75247560

0 commit comments

Comments
 (0)