mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-30 23:30:33 +01:00
Fix <NumberInput/> to allow for empty value (reset value)
This commit is contained in:
parent
00ab303e44
commit
3eabcbec72
1 changed files with 7 additions and 1 deletions
|
@ -28,7 +28,9 @@ class NumberInput extends React.Component {
|
||||||
|
|
||||||
changeValue(newValue) {
|
changeValue(newValue) {
|
||||||
this.setState({editing: true});
|
this.setState({editing: true});
|
||||||
const value = parseFloat(newValue)
|
const value = (newValue === "" || newValue === undefined) ?
|
||||||
|
undefined :
|
||||||
|
parseFloat(newValue);
|
||||||
|
|
||||||
const hasChanged = this.state.value !== value
|
const hasChanged = this.state.value !== value
|
||||||
if(this.isValid(value) && hasChanged) {
|
if(this.isValid(value) && hasChanged) {
|
||||||
|
@ -38,6 +40,10 @@ class NumberInput extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
isValid(v) {
|
isValid(v) {
|
||||||
|
if (v === undefined) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
const value = parseFloat(v)
|
const value = parseFloat(v)
|
||||||
if(isNaN(value)) {
|
if(isNaN(value)) {
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in a new issue