diff --git a/src/frontend/src/components/promptComponent/index.tsx b/src/frontend/src/components/promptComponent/index.tsx index bc30c8a99..18bf9cc01 100644 --- a/src/frontend/src/components/promptComponent/index.tsx +++ b/src/frontend/src/components/promptComponent/index.tsx @@ -10,6 +10,7 @@ import { typesContext } from "../../contexts/typesContext"; import * as _ from "lodash"; export default function PromptAreaComponent({ + field_name, setNodeClass, nodeClass, value, @@ -20,7 +21,6 @@ export default function PromptAreaComponent({ const [myValue, setMyValue] = useState(""); const { openPopUp } = useContext(PopUpContext); const { reactFlowInstance } = useContext(typesContext); - useEffect(() => { if (disabled) { setMyValue(""); @@ -29,19 +29,22 @@ export default function PromptAreaComponent({ }, [disabled, onChange]); useEffect(() => { - if (value !== "" && myValue !== value && reactFlowInstance) { // only executed once + if (value !== "" && myValue !== value && reactFlowInstance) { + // only executed once setMyValue(value); - postValidatePrompt(value, nodeClass) + postValidatePrompt(field_name, value, nodeClass) .then((apiReturn) => { if (apiReturn.data) { setNodeClass(apiReturn.data.frontend_node); // need to update reactFlowInstance to re-render the nodes. - reactFlowInstance.setEdges(_.cloneDeep(reactFlowInstance.getEdges())); + reactFlowInstance.setEdges( + _.cloneDeep(reactFlowInstance.getEdges()) + ); } }) .catch((error) => {}); } - }, [reactFlowInstance]); + }, [reactFlowInstance, field_name]); return (
-
+
{ openPopUp( @@ -70,7 +73,9 @@ export default function PromptAreaComponent({ className={ editNode ? " input-edit-node " + " input-dialog " - : (disabled ? " input-disable " : "") + " input-primary " + " input-dialog " + : (disabled ? " input-disable " : "") + + " input-primary " + + " input-dialog " } > {myValue !== "" ? myValue : "Type your prompt here"} @@ -79,6 +84,7 @@ export default function PromptAreaComponent({ onClick={() => { openPopUp( - {!editNode && } + {!editNode && ( + + )}