Skip to content

Commit 7790d89

Browse files
authored
fix(5617): composition styling not in notebooks (#5631)
* fix(5617): correctly detect when in new QxBuilder * remove extra render on keydown during typing, in order to remove erros frm missed closing paran autocomplete during CI tests
1 parent 8aa988c commit 7790d89

File tree

1 file changed

+40
-31
lines changed

1 file changed

+40
-31
lines changed

src/shared/components/FluxMonacoEditor.tsx

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Libraries
2-
import React, {FC, useEffect, useRef, useContext} from 'react'
2+
import React, {FC, useEffect, useRef, useContext, useMemo} from 'react'
33
import {useSelector} from 'react-redux'
4+
import {useRouteMatch} from 'react-router-dom'
45
import classnames from 'classnames'
56

67
// Components
@@ -67,6 +68,9 @@ const FluxEditorMonaco: FC<Props> = ({
6768
const {setEditor} = useContext(EditorContext)
6869
const isFluxQueryBuilder = useSelector(fluxQueryBuilder)
6970
const sessionStore = useContext(PersistanceContext)
71+
const {path} = useRouteMatch()
72+
const isNewQxBuilder =
73+
isFluxQueryBuilder && path === '/orgs/:orgID/data-explorer'
7074

7175
const wrapperClassName = classnames('flux-editor--monaco', {
7276
'flux-editor--monaco__autogrow': autogrow,
@@ -79,7 +83,7 @@ const FluxEditorMonaco: FC<Props> = ({
7983
useEffect(() => {
8084
if (
8185
connection.current &&
82-
isFluxQueryBuilder &&
86+
isNewQxBuilder &&
8387
isFlagEnabled('schemaComposition')
8488
) {
8589
connection.current.onSchemaSessionChange(
@@ -130,36 +134,41 @@ const FluxEditorMonaco: FC<Props> = ({
130134
onChangeScript(text)
131135
}
132136

133-
return (
134-
<ErrorBoundary>
135-
<div className={wrapperClassName} data-testid="flux-editor">
136-
<MonacoEditor
137-
language={FLUXLANGID}
138-
theme={THEME_NAME}
139-
value={script}
140-
onChange={onChange}
141-
options={{
142-
fontSize: 13,
143-
fontFamily: '"IBMPlexMono", monospace',
144-
cursorWidth: 2,
145-
lineNumbersMinChars: 4,
146-
lineDecorationsWidth: 0,
147-
minimap: {
148-
renderCharacters: false,
149-
},
150-
overviewRulerBorder: false,
151-
automaticLayout: true,
152-
readOnly: readOnly || false,
153-
wordWrap: wrapLines ?? 'off',
154-
scrollBeyondLastLine: false,
155-
}}
156-
editorDidMount={editorDidMount}
157-
/>
158-
<div id={ICON_SYNC_ID} className="sync-bar">
159-
<Icon glyph={IconFont.Sync} className="sync-icon" />
137+
return useMemo(
138+
() => (
139+
<ErrorBoundary>
140+
<div className={wrapperClassName} data-testid="flux-editor">
141+
<MonacoEditor
142+
language={FLUXLANGID}
143+
theme={THEME_NAME}
144+
value={script}
145+
onChange={onChange}
146+
options={{
147+
fontSize: 13,
148+
fontFamily: '"IBMPlexMono", monospace',
149+
cursorWidth: 2,
150+
lineNumbersMinChars: 4,
151+
lineDecorationsWidth: 0,
152+
minimap: {
153+
renderCharacters: false,
154+
},
155+
overviewRulerBorder: false,
156+
automaticLayout: true,
157+
readOnly: readOnly || false,
158+
wordWrap: wrapLines ?? 'off',
159+
scrollBeyondLastLine: false,
160+
}}
161+
editorDidMount={editorDidMount}
162+
/>
163+
{isNewQxBuilder && (
164+
<div id={ICON_SYNC_ID} className="sync-bar">
165+
<Icon glyph={IconFont.Sync} className="sync-icon" />
166+
</div>
167+
)}
160168
</div>
161-
</div>
162-
</ErrorBoundary>
169+
</ErrorBoundary>
170+
),
171+
[onChangeScript, setEditor]
163172
)
164173
}
165174

0 commit comments

Comments
 (0)