Skip to content

Commit

Permalink
Fixed #10583 - Add allowEmpty property to InputNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Sep 6, 2021
1 parent d172c58 commit 32cddd4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/app/components/inputnumber/inputnumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ export class InputNumber implements OnInit,ControlValueAccessor {

@Input() step: number = 1;

@Input() allowEmpty: boolean = true;

@Input() inputStyle: any;

@Input() inputStyleClass: string;
Expand Down Expand Up @@ -885,6 +887,7 @@ export class InputNumber implements OnInit,ControlValueAccessor {

if (valueStr != null) {
newValue = this.parseValue(valueStr);
newValue = !newValue && !this.allowEmpty ? 0 : newValue;
this.updateInput(newValue, insertedValueStr, operation, valueStr);

this.handleOnInput(event, currentValue, newValue);
Expand Down Expand Up @@ -1045,7 +1048,8 @@ export class InputNumber implements OnInit,ControlValueAccessor {
}

formattedValue() {
return this.formatValue(this.value);
const val = !this.value && !this.allowEmpty ? 0 : this.value;
return this.formatValue(val);
}

updateModel(event, value) {
Expand Down

0 comments on commit 32cddd4

Please sign in to comment.