Skip to content

Commit 00356d5

Browse files
authored
Merge pull request #7098 from IgniteUI/dkamburov/fix-6973-8.2.x
fix(filtering): Avoid resetting values for number inputs #6973
2 parents e37fac9 + 9a38c43 commit 00356d5

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
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: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import {
4646
import { HelperUtils } from '../../test-utils/helper-utils.spec';
4747
import { GridSelectionMode, FilterMode } from '../common/enums';
4848

49+
const DEBOUNCETIME = 30;
4950
const FILTER_UI_ROW = 'igx-grid-filtering-row';
5051
const FILTER_UI_CELL = 'igx-grid-filtering-cell';
5152
const FILTER_UI_SCROLL_START_CLASS = '.igx-grid__filtering-row-scroll-start';
@@ -668,6 +669,25 @@ describe('IgxGrid - Filtering actions #grid', () => {
668669
tick(100);
669670
fix.detectChanges();
670671

672+
sendInput(input, '254..', fix);
673+
tick();
674+
fix.detectChanges();
675+
676+
677+
expect(grid.rowList.length).toEqual(6);
678+
expect(close.nativeElement.classList.contains('igx-button--disabled')).toBeFalsy();
679+
expect(reset.nativeElement.classList.contains('igx-button--disabled')).toBeFalsy();
680+
expect(input.nativeElement.offsetHeight).toBeGreaterThan(0);
681+
682+
// open dropdown
683+
filterIcon.nativeElement.click();
684+
tick();
685+
fix.detectChanges();
686+
// less than or equal to
687+
ddItems[5].click();
688+
tick(100);
689+
fix.detectChanges();
690+
671691
expect(grid.rowList.length).toEqual(6);
672692
expect(close.nativeElement.classList.contains('igx-button--disabled')).toBeFalsy();
673693
expect(reset.nativeElement.classList.contains('igx-button--disabled')).toBeFalsy();
@@ -2845,9 +2865,9 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
28452865
expect(GridFunctions.getCurrentCellFromGrid(grid, 1, 1).value).toBe('Ignite UI for Angular');
28462866
}));
28472867

2848-
it('Verify filter cell chip is scrolled into view on click.', fakeAsync(() => {
2868+
it('Verify filter cell chip is scrolled into view on click.', async () => {
28492869
grid.width = '470px';
2850-
tick(100);
2870+
await wait(DEBOUNCETIME);
28512871
fix.detectChanges();
28522872

28532873
// Verify 'ReleaseDate' filter chip is not fully visible.
@@ -2858,11 +2878,11 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
28582878
'chip should not be fully visible and thus not within grid');
28592879

28602880
GridFunctions.clickFilterCellChip(fix, 'ReleaseDate');
2861-
tick(100);
2881+
await wait(DEBOUNCETIME);
28622882
fix.detectChanges();
28632883

2864-
GridFunctions.closeFilterRow(fix);
2865-
tick(100);
2884+
grid.filteringRow.close();
2885+
await wait();
28662886
fix.detectChanges();
28672887

28682888
// Verify 'ReleaseDate' filter chip is fully visible.
@@ -2871,7 +2891,7 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
28712891
gridRect = grid.nativeElement.getBoundingClientRect();
28722892
expect(chipRect.left > gridRect.left && chipRect.right < gridRect.right).toBe(true,
28732893
'chip should be fully visible and within grid');
2874-
}));
2894+
});
28752895

28762896
it('Verify condition chips are scrolled into/(out of) view by using arrow buttons.', (async () => {
28772897
grid.width = '700px';

0 commit comments

Comments
 (0)