diff --git a/canvas_modules/common-canvas/src/common-properties/controls/expression/expression.jsx b/canvas_modules/common-canvas/src/common-properties/controls/expression/expression.jsx index e81f62aba..053eb2dcd 100644 --- a/canvas_modules/common-canvas/src/common-properties/controls/expression/expression.jsx +++ b/canvas_modules/common-canvas/src/common-properties/controls/expression/expression.jsx @@ -102,8 +102,16 @@ class ExpressionControl extends React.Component { }); this.editor.focus(); } - if (!isEqual(this.getCodemirrorState()?.doc.toString(), this.props.value)) { - this.editor.dispatch({ changes: { from: 0, to: this.getCodemirrorState()?.doc?.length, insert: this.props.value } }); + if (!isEqual(prevProps.value, this.props.value)) { + const selection = this.editor.state.selection.main; + this.editor.dispatch({ + changes: { + from: 0, + to: this.getCodemirrorState()?.doc?.length, + insert: this.props.value }, + selection: { + anchor: selection.anchor, + head: selection.head } }); } }