Skip to content

Commit

Permalink
Fixed #1427 - Can't type - as first symbol into an Inputnumber
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Jul 2, 2020
1 parent 8d14342 commit 343d80c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/components/inputnumber/InputNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ export class InputNumber extends Component {

formatValue(value) {
if (value != null) {
if (value === '-') { // Minus sign
return value;
}

if (this.props.format) {
let formatter = new Intl.NumberFormat(this.props.locale, this.getOptions());
let formattedValue = formatter.format(value);
Expand Down Expand Up @@ -212,6 +216,9 @@ export class InputNumber extends Component {
.replace(this._numeral, this._index);

if (filteredText) {
if (filteredText === '-') // Minus sign
return filteredText;

let parsedValue = +filteredText;
return isNaN(parsedValue) ? null : parsedValue;
}
Expand Down

0 comments on commit 343d80c

Please sign in to comment.