Revert "CodeEditor: Ensure latest onChange callback is called" (#83677)

Revert "CodeEditor: Ensure latest onChange callback is called (#83599)"

This reverts commit 3363e3f2d3.
svennergr/recording-rules-query-type
Josh Hunt 1 year ago committed by GitHub
parent f0822e0aef
commit 0fd46a1bd3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 14
      packages/grafana-ui/src/components/Monaco/CodeEditor.tsx

@ -102,7 +102,7 @@ class UnthemedCodeEditor extends PureComponent<Props> {
};
handleOnMount = (editor: MonacoEditorType, monaco: Monaco) => {
const { getSuggestions, language, onEditorDidMount } = this.props;
const { getSuggestions, language, onChange, onEditorDidMount } = this.props;
this.modelId = editor.getModel()?.id;
this.getEditorValue = () => editor.getValue();
@ -119,21 +119,15 @@ class UnthemedCodeEditor extends PureComponent<Props> {
}
});
editor.getModel()?.onDidChangeContent(this.handleChangeContent);
if (onChange) {
editor.getModel()?.onDidChangeContent(() => onChange(editor.getValue()));
}
if (onEditorDidMount) {
onEditorDidMount(editor, monaco);
}
};
handleChangeContent = () => {
const { onChange } = this.props;
if (onChange) {
onChange(this.getEditorValue());
}
};
render() {
const { theme, language, width, height, showMiniMap, showLineNumbers, readOnly, monacoOptions } = this.props;
const { alwaysConsumeMouseWheel, ...restMonacoOptions } = monacoOptions ?? {};

Loading…
Cancel
Save