From d42925c16c5ebf5c19120981775e59a16187d5bb Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Wed, 15 May 2024 13:59:50 +0200 Subject: [PATCH] Fixed Undo bug adding Skip Snapshot to function that resets inputs when disabled --- .../src/components/codeAreaComponent/index.tsx | 4 ++-- .../src/components/floatComponent/index.tsx | 2 +- .../src/components/inputComponent/index.tsx | 2 +- .../src/components/inputFileComponent/index.tsx | 6 +++--- .../src/components/inputGlobalComponent/index.tsx | 14 +++++++------- src/frontend/src/components/intComponent/index.tsx | 2 +- .../src/components/promptComponent/index.tsx | 2 +- .../src/components/textAreaComponent/index.tsx | 2 +- .../components/parameterComponent/index.tsx | 3 ++- src/frontend/src/types/components/index.ts | 14 +++++++------- 10 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/frontend/src/components/codeAreaComponent/index.tsx b/src/frontend/src/components/codeAreaComponent/index.tsx index af599e1d8..cd8a0f77d 100644 --- a/src/frontend/src/components/codeAreaComponent/index.tsx +++ b/src/frontend/src/components/codeAreaComponent/index.tsx @@ -18,12 +18,12 @@ export default function CodeAreaComponent({ setOpen, }: CodeAreaComponentType) { const [myValue, setMyValue] = useState( - typeof value == "string" ? value : JSON.stringify(value) + typeof value == "string" ? value : JSON.stringify(value), ); useEffect(() => { if (disabled && myValue !== "") { setMyValue(""); - onChange(""); + onChange("", true); } }, [disabled]); diff --git a/src/frontend/src/components/floatComponent/index.tsx b/src/frontend/src/components/floatComponent/index.tsx index a4ebf1ae9..8db5b823a 100644 --- a/src/frontend/src/components/floatComponent/index.tsx +++ b/src/frontend/src/components/floatComponent/index.tsx @@ -16,7 +16,7 @@ export default function FloatComponent({ // Clear component state useEffect(() => { if (disabled && value !== "") { - onChange(""); + onChange("", true); } }, [disabled]); diff --git a/src/frontend/src/components/inputComponent/index.tsx b/src/frontend/src/components/inputComponent/index.tsx index b1b4b9ef9..b285a1874 100644 --- a/src/frontend/src/components/inputComponent/index.tsx +++ b/src/frontend/src/components/inputComponent/index.tsx @@ -48,7 +48,7 @@ export default function InputComponent({ // Clear component state useEffect(() => { if (disabled && value && onChange && value !== "") { - onChange(""); + onChange("", true); } }, [disabled]); diff --git a/src/frontend/src/components/inputFileComponent/index.tsx b/src/frontend/src/components/inputFileComponent/index.tsx index 688ea8d97..fb83b18fb 100644 --- a/src/frontend/src/components/inputFileComponent/index.tsx +++ b/src/frontend/src/components/inputFileComponent/index.tsx @@ -27,7 +27,7 @@ export default function InputFileComponent({ useEffect(() => { if (disabled && value !== "") { setMyValue(""); - onChange(""); + onChange("", true); onFileChange(""); } }, [disabled, onChange]); @@ -106,8 +106,8 @@ export default function InputFileComponent({ editNode ? "input-edit-node input-dialog text-muted-foreground" : disabled - ? "input-disable input-dialog primary-input" - : "input-dialog primary-input text-muted-foreground" + ? "input-disable input-dialog primary-input" + : "input-dialog primary-input text-muted-foreground" } > {myValue !== "" ? myValue : "No file"} diff --git a/src/frontend/src/components/inputGlobalComponent/index.tsx b/src/frontend/src/components/inputGlobalComponent/index.tsx index 3e6b340cb..2ca1aed22 100644 --- a/src/frontend/src/components/inputGlobalComponent/index.tsx +++ b/src/frontend/src/components/inputGlobalComponent/index.tsx @@ -19,15 +19,15 @@ export default function InputGlobalComponent({ editNode = false, }: InputGlobalComponentType): JSX.Element { const globalVariablesEntries = useGlobalVariablesStore( - (state) => state.globalVariablesEntries + (state) => state.globalVariablesEntries, ); const getVariableId = useGlobalVariablesStore((state) => state.getVariableId); const unavaliableFields = useGlobalVariablesStore( - (state) => state.unavaliableFields + (state) => state.unavaliableFields, ); const removeGlobalVariable = useGlobalVariablesStore( - (state) => state.removeGlobalVariable + (state) => state.removeGlobalVariable, ); const setErrorData = useAlertStore((state) => state.setErrorData); @@ -38,7 +38,7 @@ export default function InputGlobalComponent({ data.node?.template[name].load_from_db ) { setTimeout(() => { - onChange(""); + onChange("", true); setDb(false); }, 100); } @@ -129,7 +129,7 @@ export default function InputGlobalComponent({