From f2d34254d3b2d7e23e39cf17c99374f96a0d09e7 Mon Sep 17 00:00:00 2001 From: jackyin <648588267@qq.com> Date: Tue, 11 Feb 2025 15:51:59 +0800 Subject: [PATCH] Panel: Editor theme can't change (#99621) editor theme can't change --- .../src/components/Monaco/ReactMonacoEditor.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/grafana-ui/src/components/Monaco/ReactMonacoEditor.tsx b/packages/grafana-ui/src/components/Monaco/ReactMonacoEditor.tsx index 2d095d6d182..56714d927c6 100644 --- a/packages/grafana-ui/src/components/Monaco/ReactMonacoEditor.tsx +++ b/packages/grafana-ui/src/components/Monaco/ReactMonacoEditor.tsx @@ -1,6 +1,6 @@ import Editor, { loader as monacoEditorLoader, Monaco } from '@monaco-editor/react'; import * as monaco from 'monaco-editor'; -import { useCallback } from 'react'; +import { useCallback, useEffect } from 'react'; import { useTheme2 } from '../../themes'; @@ -16,12 +16,15 @@ export const ReactMonacoEditor = (props: ReactMonacoEditorProps) => { const theme = useTheme2(); const onMonacoBeforeMount = useCallback( (monaco: Monaco) => { - defineThemes(monaco, theme); beforeMount?.(monaco); }, - [beforeMount, theme] + [beforeMount] ); + useEffect(() => { + defineThemes(monaco, theme); + }, [theme]); + return (