From 4f8f950be231b742150eb0634da8643b398e797c Mon Sep 17 00:00:00 2001 From: Guillaume Castellant Date: Thu, 9 Mar 2017 10:53:05 +0100 Subject: [PATCH 1/2] Fixed backspace on dot in float value --- src/NumericInput.jsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NumericInput.jsx b/src/NumericInput.jsx index 93d4e7c..b3834b8 100644 --- a/src/NumericInput.jsx +++ b/src/NumericInput.jsx @@ -543,6 +543,11 @@ class NumericInput extends Component */ _parse(x: string): number { + // prevent backspace on dot in float value + if (this.props.precision > 0 && x.indexOf(".") < 0) { + x = this.state.value; + } + if (typeof this.props.parse == 'function') { return parseFloat(this.props.parse(x)); } From e38fcc3cee8c303cfef2eb75961d8c297698fb58 Mon Sep 17 00:00:00 2001 From: Guillaume Castellant Date: Fri, 17 Mar 2017 15:29:07 +0100 Subject: [PATCH 2/2] fix error with no default value --- src/NumericInput.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NumericInput.jsx b/src/NumericInput.jsx index b3834b8..168a039 100644 --- a/src/NumericInput.jsx +++ b/src/NumericInput.jsx @@ -544,7 +544,7 @@ class NumericInput extends Component _parse(x: string): number { // prevent backspace on dot in float value - if (this.props.precision > 0 && x.indexOf(".") < 0) { + if (this.props.precision > 0 && this.state.value !== null && !isNaN(this.state.value) && x.length > 0 && x.indexOf(".") < 0) { x = this.state.value; }