diff --git a/ui/src/app/shared/components/monaco-editor.tsx b/ui/src/app/shared/components/monaco-editor.tsx index 54a403365f447..3b114c9f7d452 100644 --- a/ui/src/app/shared/components/monaco-editor.tsx +++ b/ui/src/app/shared/components/monaco-editor.tsx @@ -30,6 +30,7 @@ const MonacoEditorLazy = React.lazy(() => const Component = (props: MonacoProps) => { const [height, setHeight] = React.useState(0); const [theme, setTheme] = React.useState('dark'); + const editorApiRef = React.useRef(null); React.useEffect(() => { const destroySystemThemeListener = useSystemTheme(systemTheme => { @@ -55,6 +56,16 @@ const MonacoEditorLazy = React.lazy(() => }; }, []); + React.useEffect(() => { + const onResize = () => { + editorApiRef.current?.layout(); + }; + window.addEventListener('resize', onResize); + return () => { + window.removeEventListener('resize', onResize); + }; + }, []); + return (
}); container.editorApi = editor; + editorApiRef.current = editor; } const model = monaco.editor.createModel(props.editor.input.text, props.editor.input.language);