diff --git a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx index 72c2a8e4d..dca4866d1 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx @@ -321,11 +321,16 @@ export default function ParameterComponent({ field_name={name} setNodeClass={(nodeClass) => { data.node = nodeClass; + const clone = cloneDeep(data); + clone.node = nodeClass; + setData(clone); }} nodeClass={data.node} disabled={disabled} value={data.node.template[name].value ?? ""} - onChange={handleOnNewValue} + onChange={(e) => { + handleOnNewValue(e); + }} /> ) : ( diff --git a/src/frontend/src/modals/genericModal/index.tsx b/src/frontend/src/modals/genericModal/index.tsx index 9175cac07..5935e2184 100644 --- a/src/frontend/src/modals/genericModal/index.tsx +++ b/src/frontend/src/modals/genericModal/index.tsx @@ -1,4 +1,3 @@ -import { cloneDeep } from "lodash"; import { ReactNode, useContext, useEffect, useRef, useState } from "react"; import SanitizedHTMLWrapper from "../../components/SanitizedHTMLWrapper"; import ShadTooltip from "../../components/ShadTooltipComponent"; @@ -133,21 +132,21 @@ export default function GenericModal({ function validatePrompt(closeModal: boolean): void { //nodeClass is always null on tweaks - if (nodeClass) { - const nodeClassCp = cloneDeep(nodeClass); - nodeClassCp["template"]["template"]["value"] = inputValue; - nodeClass = nodeClassCp; - } + postValidatePrompt(field_name, inputValue, nodeClass!) .then((apiReturn) => { if (apiReturn.data) { + setValue(inputValue); + apiReturn.data.frontend_node["template"]["template"]["value"] = + inputValue; + setNodeClass!(apiReturn?.data?.frontend_node); + let inputVariables = apiReturn.data.input_variables ?? []; if (inputVariables && inputVariables.length === 0) { setIsEdit(true); setNoticeData({ title: "Your template does not have any variables.", }); - setNodeClass!(apiReturn?.data?.frontend_node); setModalOpen(closeModal); } else { setIsEdit(false); @@ -157,9 +156,9 @@ export default function GenericModal({ if ( JSON.stringify(apiReturn.data?.frontend_node) !== JSON.stringify({}) - ) + ) { setModalOpen(closeModal); - setValue(inputValue); + } } } else { setIsEdit(true); @@ -306,9 +305,7 @@ export default function GenericModal({ setModalOpen(false); break; case TypeModal.PROMPT: - !inputValue || inputValue === "" - ? setModalOpen(false) - : validatePrompt(false); + validatePrompt(false); break; default: diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts index 9a42c5f04..d21028c70 100644 --- a/src/frontend/src/utils/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -200,10 +200,9 @@ export function validateNode( e.targetHandle.split("|")[2] === n.id ) ? [ - `${type} is missing ${ - template.display_name || toNormalCase(template[t].name) - }.`, - ] + `${type} is missing ${template.display_name || toNormalCase(template[t].name) + }.`, + ] : [] ), [] as string[] @@ -239,7 +238,6 @@ export function handleKeyDown( inputValue: string | string[] | null, block: string ) { - console.log(e, inputValue, block); //condition to fix bug control+backspace on Windows/Linux if ( (typeof inputValue === "string" &&