fix cursor jumping at the end after every editor update

main
slorber 7 years ago committed by Brian Dennis
parent 497188aa1a
commit 4cfbb8f3d1

@ -102,7 +102,7 @@ class Carbon extends React.Component {
{config.windowControls ? <WindowControls theme={config.windowTheme} /> : null}
<CodeMirror
className={`CodeMirror__container window-theme__${config.windowTheme}`}
onChange={(editor, meta, code) => this.codeUpdated(code)}
onBeforeChange={(editor, meta, code) => this.codeUpdated(code)}
value={this.props.children}
options={options}
/>

@ -1,6 +1,6 @@
// For SSR, CodeMirror will throw an error, so return a div instead
let CodeMirror = 'div'
if (typeof window !== 'undefined' && typeof window.navigator !== 'undefined') {
CodeMirror = require('react-codemirror2').UnControlled
CodeMirror = require('react-codemirror2').Controlled
}
export default CodeMirror

Loading…
Cancel
Save