mirror of
https://github.com/maputnik/editor.git
synced 2026-01-06 21:40:01 +00:00
Reset JSONEditor after it loosed focus
This commit is contained in:
@@ -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}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user