Fixes inputting negative numbers from gauges

pull/10616/head
Brandon Farmer 2018-05-01 14:40:21 -07:00
parent 5d8835e8f5
commit f232853ef1
1 changed files with 4 additions and 4 deletions

View File

@ -32,7 +32,7 @@ interface Props {
} }
interface State { interface State {
workingValue: number workingValue: number | string
valid: boolean valid: boolean
} }
@ -143,9 +143,9 @@ class Threshold extends PureComponent<Props, State> {
private handleChangeWorkingValue = (e: ChangeEvent<HTMLInputElement>) => { private handleChangeWorkingValue = (e: ChangeEvent<HTMLInputElement>) => {
const {threshold, onValidateColorValue} = this.props const {threshold, onValidateColorValue} = this.props
const targetValue = Number(e.target.value) const targetValue = e.target.value
const valid = onValidateColorValue(threshold, targetValue) const valid = onValidateColorValue(threshold, Number(targetValue))
this.setState({valid, workingValue: targetValue}) this.setState({valid, workingValue: targetValue})
} }
@ -155,7 +155,7 @@ class Threshold extends PureComponent<Props, State> {
const {threshold, onUpdateColorValue} = this.props const {threshold, onUpdateColorValue} = this.props
if (valid) { if (valid) {
onUpdateColorValue(threshold, workingValue) onUpdateColorValue(threshold, Number(workingValue))
} else { } else {
this.setState({workingValue: threshold.value, valid: true}) this.setState({workingValue: threshold.value, valid: true})
} }