diff --git a/webapp/src/components/Inputs/InputYaml.tsx b/webapp/src/components/Inputs/InputYaml.tsx index 49d7f56..75799b6 100644 --- a/webapp/src/components/Inputs/InputYaml.tsx +++ b/webapp/src/components/Inputs/InputYaml.tsx @@ -34,21 +34,21 @@ export default function InputYaml({ helperText, endAdornment, }: Props) { - const [{ text, error, hasChanged }, setState] = useState<{ + const originalText = yaml.dump(value); + const [{ text, error }, setState] = useState<{ text: string; error: undefined | JSX.Element | string; - hasChanged: boolean; }>({ - text: yaml.dump(value), + text: originalText, error: incmError, - hasChanged: false, }); + const hasChanged = text !== originalText; const setText = (t: string) => { try { yaml.load(t); - setState({ text: t, error: undefined, hasChanged: true }); + setState({ text: t, error: undefined }); } catch (_) { - setState({ text: t, error: "! Invalid Yaml !", hasChanged: true }); + setState({ text: t, error: "! Invalid Yaml !" }); } }; const onSave = () => { @@ -60,18 +60,12 @@ export default function InputYaml({ } else { onChange({} as any); } - setState({ - text, - error, - hasChanged: false, - }); } }; useEffect(() => { setState({ text: yaml.dump(value), error: incmError, - hasChanged: false, }); }, [value, incmError]); return ( @@ -90,6 +84,7 @@ export default function InputYaml({ onChange={setText} maxWidth="100%" width="100%" + minHeight="3.5em" minWidth="100%" /> diff --git a/webapp/src/components/NodeEditor/OptionManager/index.tsx b/webapp/src/components/NodeEditor/OptionManager/index.tsx index 3a0ad82..7a5df23 100644 --- a/webapp/src/components/NodeEditor/OptionManager/index.tsx +++ b/webapp/src/components/NodeEditor/OptionManager/index.tsx @@ -54,6 +54,7 @@ export const useEditorNodeState = ( setAllState({ ...allState, ...computeInvalidYaml(yaml, allowedTypes), + isModified: true, }); }; // value aliases