From 3eabcbec72f7d74008dc980dd8cc14bdcd6b1245 Mon Sep 17 00:00:00 2001 From: orangemug Date: Sun, 13 Oct 2019 18:00:32 +0100 Subject: [PATCH] Fix to allow for empty value (reset value) --- src/components/inputs/NumberInput.jsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/inputs/NumberInput.jsx b/src/components/inputs/NumberInput.jsx index 3071e35c..369f9833 100644 --- a/src/components/inputs/NumberInput.jsx +++ b/src/components/inputs/NumberInput.jsx @@ -28,7 +28,9 @@ class NumberInput extends React.Component { changeValue(newValue) { this.setState({editing: true}); - const value = parseFloat(newValue) + const value = (newValue === "" || newValue === undefined) ? + undefined : + parseFloat(newValue); const hasChanged = this.state.value !== value if(this.isValid(value) && hasChanged) { @@ -38,6 +40,10 @@ class NumberInput extends React.Component { } isValid(v) { + if (v === undefined) { + return true; + } + const value = parseFloat(v) if(isNaN(value)) { return false