File tree Expand file tree Collapse file tree 3 files changed +17
-4
lines changed
frontend/packages/console-shared/src/components/editor Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change 11import * as React from 'react' ;
22import { loader , Monaco } from '@monaco-editor/react' ;
33import { CodeEditor } from '@patternfly/react-code-editor' ;
4+ import { getResizeObserver } from '@patternfly/react-core' ;
45import classNames from 'classnames' ;
56import * as monaco from 'monaco-editor' ;
67import { useTranslation } from 'react-i18next' ;
@@ -23,6 +24,22 @@ export const BasicCodeEditor: React.FC<BasicCodeEditorProps> = (props) => {
2324 const [ monacoRef , setMonacoRef ] = React . useState < Monaco | null > ( null ) ;
2425 useConsoleMonacoTheme ( monacoRef ?. editor ) ;
2526
27+ // TODO(PF6): remove this when https://github.com/patternfly/patternfly-react/issues/11531 is fixed
28+ const handleResize = React . useCallback ( ( ) => {
29+ monacoRef ?. editor ?. getEditors ( ) ?. forEach ( ( editor ) => {
30+ editor . layout ( { width : 0 , height : 0 } ) ;
31+ editor . layout ( ) ;
32+ } ) ;
33+ } , [ monacoRef ] ) ;
34+
35+ React . useEffect ( ( ) => {
36+ const observer = getResizeObserver ( undefined , handleResize , true ) ;
37+
38+ return ( ) => {
39+ observer ( ) ;
40+ } ;
41+ } , [ handleResize ] ) ;
42+
2643 return (
2744 < CodeEditor
2845 copyButtonAriaLabel = { t ( 'Copy code to clipboard' ) }
Original file line number Diff line number Diff line change 22
33.ocs-yaml-editor {
44 .monaco-editor {
5- // Makes automaticLayout work properly. note that this breaks height="sizeToFit"
6- position : absolute !important ;
7-
85 .monaco-hover-content .markdown-hover {
96 // matches tooltip styling seen back in OpenShift 4.18
107 max-width : 500px ;
Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ import { getSwaggerDefinitions } from '@console/internal/module/k8s/swagger';
77
88export const defaultEditorOptions : monaco . editor . IEditorOptions = {
99 scrollBeyondLastLine : false ,
10- automaticLayout : true , // paired with position: absolute for auto-resizing
1110} ;
1211
1312const findManagedMetadata = ( model : monaco . editor . ITextModel ) => {
You can’t perform that action at this time.
0 commit comments