Skip to content

Commit 0a04cbb

Browse files
authored
Merge pull request #390 from MOV-AI/FP-3050-configurations-toggle-between-xml-and-yaml-isnt-highlighting-in-real-time
FP-3050: Configurations: Toggle between XML and YAML isn't highlighting in real-time
2 parents 98f9dcb + 13a4b80 commit 0a04cbb

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# TBD
22

3+
- [FP-3050](https://movai.atlassian.net/browse/FP-3050): Configurations: Toggle between XML and YAML isn't highlighting in real-time
34
- [FP-3107](https://movai.atlassian.net/browse/FP-3107): IDE: File selection context disappeared
45

56
# v1.4.5

src/editors/Configuration/view/Configuration.jsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback } from "react";
1+
import React, { useCallback, useMemo, useState } from "react";
22
import PropTypes from "prop-types";
33
import { i18n } from "@mov-ai/mov-fe-lib-react";
44
import { MonacoCodeEditor } from "@mov-ai/mov-fe-lib-code-editor";
@@ -31,6 +31,7 @@ export const Configuration = (props, ref) => {
3131
propsData: props.data,
3232
keysToDisconsider: Model.KEYS_TO_DISCONSIDER,
3333
});
34+
const [extension, setExtension] = useState("yaml");
3435
// Style Hooks
3536
const classes = configurationStyles();
3637
const theme = useTheme();
@@ -99,6 +100,7 @@ export const Configuration = (props, ref) => {
99100
*/
100101
const handleChangeFileType = (event, newExtension) => {
101102
event.stopPropagation();
103+
setExtension(newExtension);
102104
updateConfigExtension(newExtension);
103105
};
104106

@@ -116,15 +118,15 @@ export const Configuration = (props, ref) => {
116118
* */
117119
//========================================================================================
118120

119-
const renderEditor = () => {
121+
const editorEl = useMemo(() => {
120122
return (
121123
<div
122124
data-testid="section_configuration-editor"
123125
className={classes.codeContainer}
124126
>
125127
<MonacoCodeEditor
126128
value={data.code}
127-
language={data.extension}
129+
language={extension}
128130
theme={theme.codeEditor?.theme}
129131
options={{ readOnly: !editable }}
130132
onChange={updateConfigCode}
@@ -133,7 +135,7 @@ export const Configuration = (props, ref) => {
133135
/>
134136
</div>
135137
);
136-
};
138+
}, [extension, classes.codeContainer, data.code]);
137139

138140
return (
139141
<div
@@ -157,7 +159,7 @@ export const Configuration = (props, ref) => {
157159
</ToggleButtonGroup>
158160
</Toolbar>
159161
</AppBar>
160-
{renderEditor()}
162+
{editorEl}
161163
</div>
162164
);
163165
};

0 commit comments

Comments
 (0)