mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-28 17:11:17 +01:00
StringInput triggers change on out of focus #46
This commit is contained in:
parent
a1dfeca6e0
commit
85cef2945d
1 changed files with 19 additions and 2 deletions
|
@ -9,15 +9,32 @@ class StringInput extends React.Component {
|
|||
onChange: React.PropTypes.func,
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.state = {
|
||||
value: props.value
|
||||
}
|
||||
}
|
||||
|
||||
changeValue(newValue) {
|
||||
//TODO: In feature we can try to do validation here as well
|
||||
this.setState({ value: newValue })
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
this.setState({ value: nextProps.value })
|
||||
}
|
||||
|
||||
render() {
|
||||
return <input
|
||||
style={{
|
||||
...input.input,
|
||||
...this.props.style
|
||||
}}
|
||||
value={this.props.value}
|
||||
value={this.state.value}
|
||||
placeholder={this.props.default}
|
||||
onChange={e => this.props.onChange(e.target.value)}
|
||||
onChange={e => this.changeValue(e.target.value)}
|
||||
onBlur={() => this.props.onChange(this.state.value)}
|
||||
/>
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue