From f05e0b197ea6f584fa340c5606f6962171b3ae44 Mon Sep 17 00:00:00 2001 From: Deyan Kamburov Date: Thu, 9 Apr 2020 18:32:53 +0300 Subject: [PATCH] fix(filtering): Avoid reseting values for number inputs #6973 --- .../grids/filtering/base/grid-filtering-row.component.ts | 9 ++++++--- .../src/lib/grids/grid/grid-filtering-ui.spec.ts | 7 +++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/projects/igniteui-angular/src/lib/grids/filtering/base/grid-filtering-row.component.ts b/projects/igniteui-angular/src/lib/grids/filtering/base/grid-filtering-row.component.ts index d94b526186d..7cbb0df84b0 100644 --- a/projects/igniteui-angular/src/lib/grids/filtering/base/grid-filtering-row.component.ts +++ b/projects/igniteui-angular/src/lib/grids/filtering/base/grid-filtering-row.component.ts @@ -24,7 +24,7 @@ import { IBaseChipEventArgs, IgxChipsAreaComponent, IgxChipComponent } from '../ import { ExpressionUI } from '../grid-filtering.service'; import { IgxDropDownItemComponent } from '../../../drop-down/drop-down-item.component'; import { IgxFilteringService } from '../grid-filtering.service'; -import { KEYS, isEdge } from '../../../core/utils'; +import { KEYS, isEdge, isIE } from '../../../core/utils'; import { AbsoluteScrollStrategy } from '../../../services/overlay/scroll'; /** @@ -262,8 +262,11 @@ export class IgxGridFilteringRowComponent implements AfterViewInit { public onInput(eventArgs) { // The 'iskeyPressed' flag is needed for a case in IE, because the input event is fired on focus and for some reason, // when you have a japanese character as a placeholder, on init the value here is empty string . - if (isEdge() || this.isKeyPressed || eventArgs.target.value) { - this.value = eventArgs.target.value; + // There is no need to reset the value on every invalid number input. + // The invalid value is converted to empty string input type="number" + const target = eventArgs.target; + if (isEdge() && target.type !== 'number' || this.isKeyPressed && isIE() || target.value) { + this.value = target.value; } } diff --git a/projects/igniteui-angular/src/lib/grids/grid/grid-filtering-ui.spec.ts b/projects/igniteui-angular/src/lib/grids/grid/grid-filtering-ui.spec.ts index 8dd97b2593b..ada3c215163 100644 --- a/projects/igniteui-angular/src/lib/grids/grid/grid-filtering-ui.spec.ts +++ b/projects/igniteui-angular/src/lib/grids/grid/grid-filtering-ui.spec.ts @@ -229,6 +229,13 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => { expect(grid.rowList.length).toEqual(3); verifyFilterRowUI(input, close, reset, false); + + // greater than or equal to with invalid value should not reset filter + GridFunctions.openFilterDDAndSelectCondition(fix, 4); + GridFunctions.typeValueInFilterRowInput('254..', fix, input); + + expect(grid.rowList.length).toEqual(3); + verifyFilterRowUI(input, close, reset, false); })); // UI tests boolean column