Skip to content

Commit 74db265

Browse files
committed
fix(grid): allow values between -1 and 0
1 parent f50aa0d commit 74db265

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,13 @@ export class IgxGridFilteringRowComponent implements AfterViewInit, OnDestroy {
8080

8181
@Input()
8282
public get value(): any {
83-
return this.expression ? this.expression.searchVal : null;
83+
return this._value;
8484
}
8585

8686
public set value(val) {
8787
if (!val && val !== 0 && (this.expression.searchVal || this.expression.searchVal === 0)) {
8888
this.expression.searchVal = null;
89+
this._value = null;
8990
const index = this.expressionsList.findIndex(item => item.expression === this.expression);
9091
if (index === 0 && this.expressionsList.length === 1) {
9192
this.filteringService.clearFilter(this.column.field);
@@ -105,6 +106,7 @@ export class IgxGridFilteringRowComponent implements AfterViewInit, OnDestroy {
105106
return;
106107
}
107108

109+
this._value = val;
108110
this.expression.searchVal = DataUtil.parseValue(this.column.dataType, val);
109111
if (this.expressionsList.find(item => item.expression === this.expression) === undefined) {
110112
this.addExpression(true);
@@ -209,6 +211,7 @@ export class IgxGridFilteringRowComponent implements AfterViewInit, OnDestroy {
209211
private isKeyPressed = false;
210212
private isComposing = false;
211213
private _cancelChipClick = false;
214+
private _value = null;
212215

213216
/** switch to icon buttons when width is below 432px */
214217
private readonly NARROW_WIDTH_THRESHOLD = 432;
@@ -238,6 +241,7 @@ export class IgxGridFilteringRowComponent implements AfterViewInit, OnDestroy {
238241
const selectedItem = this.expressionsList.find(expr => expr.isSelected === true);
239242
if (selectedItem) {
240243
this.expression = selectedItem.expression;
244+
this._value = this.expression.searchVal;
241245
}
242246

243247
this.filteringService.grid.localeChange
@@ -358,9 +362,6 @@ export class IgxGridFilteringRowComponent implements AfterViewInit, OnDestroy {
358362
// The 'iskeyPressed' flag is needed for a case in IE, because the input event is fired on focus and for some reason,
359363
// when you have a japanese character as a placeholder, on init the value here is empty string .
360364
const target = eventArgs.target;
361-
if ((eventArgs.data === '-' || eventArgs.data === '+') && this.column.dataType === GridColumnDataType.Number) {
362-
return;
363-
}
364365
if (this.column.dataType === GridColumnDataType.DateTime) {
365366
this.value = eventArgs;
366367
return;
@@ -464,6 +465,7 @@ export class IgxGridFilteringRowComponent implements AfterViewInit, OnDestroy {
464465
this.removeExpression(indexToDeselect, this.expression);
465466
}
466467
this.resetExpression();
468+
this._value = this.expression.searchVal;
467469
this.scrollChipsWhenAddingExpression();
468470
}
469471

@@ -637,7 +639,7 @@ export class IgxGridFilteringRowComponent implements AfterViewInit, OnDestroy {
637639
item.isSelected = !item.isSelected;
638640
if (item.isSelected) {
639641
this.expression = item.expression;
640-
642+
this._value = this.expression.searchVal;
641643
this.focusEditElement();
642644
}
643645
}

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,14 +919,19 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
919919
// Set input and confirm
920920
GridFunctions.typeValueInFilterRowInput('-1', fix);
921921

922-
expect(input.componentInstance.value).toEqual(-1);
922+
expect(input.componentInstance.value).toEqual('-1');
923923
expect(grid.rowList.length).toEqual(1);
924924

925925
GridFunctions.typeValueInFilterRowInput('0', fix);
926926

927-
expect(input.componentInstance.value).toEqual(0);
927+
expect(input.componentInstance.value).toEqual('0');
928928
expect(grid.rowList.length).toEqual(0);
929929

930+
GridFunctions.typeValueInFilterRowInput('-0.5', fix);
931+
932+
expect(input.componentInstance.value).toEqual('-0.5');
933+
expect(grid.rowList.length).toEqual(1);
934+
930935
GridFunctions.typeValueInFilterRowInput('', fix);
931936

932937
expect(input.componentInstance.value).toEqual(null);

projects/igniteui-angular/src/lib/test-utils/sample-test-data.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class SampleTestData {
7272
public static numericData = () => ([
7373
{ Number: -1 },
7474
{ Number: 2.5 },
75-
{ Number: 35 }
75+
{ Number: -0.5 }
7676
]);
7777

7878
/* Fields: Name: string, Avatar: string; 3 items. */

0 commit comments

Comments
 (0)