mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-28 17:31:14 +01:00
Reset JSONEditor after it loosed focus
This commit is contained in:
parent
c3a634b216
commit
e00cdde3af
1 changed files with 8 additions and 0 deletions
|
@ -56,6 +56,13 @@ class JSONEditor extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetValue() {
|
||||||
|
console.log('reset')
|
||||||
|
this.setState({
|
||||||
|
code: JSON.stringify(this.props.layer, null, 2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const codeMirrorOptions = {
|
const codeMirrorOptions = {
|
||||||
mode: {name: "javascript", json: true},
|
mode: {name: "javascript", json: true},
|
||||||
|
@ -69,6 +76,7 @@ class JSONEditor extends React.Component {
|
||||||
return <CodeMirror
|
return <CodeMirror
|
||||||
value={this.state.code}
|
value={this.state.code}
|
||||||
onChange={this.onCodeUpdate.bind(this)}
|
onChange={this.onCodeUpdate.bind(this)}
|
||||||
|
onFocusChange={focused => focused ? true : this.resetValue()}
|
||||||
options={codeMirrorOptions}
|
options={codeMirrorOptions}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue