Skip to content

Commit 85f6767

Browse files
committed
fix(filtering): Avoid reseting values for number inputs #6973
1 parent f3c4821 commit 85f6767

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { IBaseChipEventArgs, IgxChipsAreaComponent, IgxChipComponent } from '../
2424
import { ExpressionUI } from './grid-filtering.service';
2525
import { IgxDropDownItemComponent } from '../../drop-down/drop-down-item.component';
2626
import { IgxFilteringService } from './grid-filtering.service';
27-
import { KEYS, isEdge } from '../../core/utils';
27+
import { KEYS, isEdge, isIE } from '../../core/utils';
2828
import { AbsoluteScrollStrategy } from '../../services/overlay/scroll';
2929

3030
/**
@@ -281,8 +281,11 @@ export class IgxGridFilteringRowComponent implements AfterViewInit {
281281
public onInput(eventArgs) {
282282
// The 'iskeyPressed' flag is needed for a case in IE, because the input event is fired on focus and for some reason,
283283
// when you have a japanese character as a placeholder, on init the value here is empty string .
284-
if (isEdge() || this.isKeyPressed || eventArgs.target.value) {
285-
this.value = eventArgs.target.value;
284+
// There is no need to reset the value on every invalid number input.
285+
// The invalid value is converted to empty string input type="number"
286+
const target = eventArgs.target;
287+
if (isEdge() && target.type !== 'number' || this.isKeyPressed && isIE() || target.value) {
288+
this.value = target.value;
286289
}
287290
}
288291

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,25 @@ describe('IgxGrid - Filtering actions #grid', () => {
668668
tick(100);
669669
fix.detectChanges();
670670

671+
sendInput(input, '254..', fix);
672+
tick();
673+
fix.detectChanges();
674+
675+
676+
expect(grid.rowList.length).toEqual(6);
677+
expect(close.nativeElement.classList.contains('igx-button--disabled')).toBeFalsy();
678+
expect(reset.nativeElement.classList.contains('igx-button--disabled')).toBeFalsy();
679+
expect(input.nativeElement.offsetHeight).toBeGreaterThan(0);
680+
681+
// open dropdown
682+
filterIcon.nativeElement.click();
683+
tick();
684+
fix.detectChanges();
685+
// less than or equal to
686+
ddItems[5].click();
687+
tick(100);
688+
fix.detectChanges();
689+
671690
expect(grid.rowList.length).toEqual(6);
672691
expect(close.nativeElement.classList.contains('igx-button--disabled')).toBeFalsy();
673692
expect(reset.nativeElement.classList.contains('igx-button--disabled')).toBeFalsy();

0 commit comments

Comments
 (0)