From e00cdde3affcefa78f6d3971a470b636517af2c2 Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Sat, 31 Dec 2016 14:37:40 +0100 Subject: [PATCH] Reset JSONEditor after it loosed focus --- src/components/layers/JSONEditor.jsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/layers/JSONEditor.jsx b/src/components/layers/JSONEditor.jsx index 2271c99..c996023 100644 --- a/src/components/layers/JSONEditor.jsx +++ b/src/components/layers/JSONEditor.jsx @@ -56,6 +56,13 @@ class JSONEditor extends React.Component { } } + resetValue() { + console.log('reset') + this.setState({ + code: JSON.stringify(this.props.layer, null, 2) + }) + } + render() { const codeMirrorOptions = { mode: {name: "javascript", json: true}, @@ -69,6 +76,7 @@ class JSONEditor extends React.Component { return focused ? true : this.resetValue()} options={codeMirrorOptions} /> }