[v10.1.x] CodeEditor: Correctly fires onChange handler (#73261)

CodeEditor: Correctly fires onChange handler (#73030)

move onChange outside onEditorDidMount condition

(cherry picked from commit 57d8997b86)

Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
This commit is contained in:
grafana-delivery-bot[bot]
2023-08-15 11:32:51 +03:00
committed by GitHub
co-authored by Ashley Harrison
parent e56b01975c
commit b8556eab5f
@@ -111,9 +111,12 @@ class UnthemedCodeEditor extends PureComponent<Props> {
const languagePromise = this.loadCustomLanguage();
if (onChange) {
editor.getModel()?.onDidChangeContent(() => onChange(editor.getValue()));
}
if (onEditorDidMount) {
languagePromise.then(() => onEditorDidMount(editor, monaco));
editor.getModel()?.onDidChangeContent(() => onChange?.(editor.getValue()));
}
};