From 0a28c72bad6914d541c349bf72f7a7601d85c6d9 Mon Sep 17 00:00:00 2001 From: Bently Date: Tue, 9 Jul 2024 16:21:13 +0100 Subject: [PATCH] Fix issue with node inputs (#7356) --- rnd/autogpt_builder/src/components/CustomNode.tsx | 2 +- rnd/autogpt_builder/src/components/ModalComponent.tsx | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/rnd/autogpt_builder/src/components/CustomNode.tsx b/rnd/autogpt_builder/src/components/CustomNode.tsx index 4db87dac2..c4cbdd3b3 100644 --- a/rnd/autogpt_builder/src/components/CustomNode.tsx +++ b/rnd/autogpt_builder/src/components/CustomNode.tsx @@ -5,7 +5,6 @@ import './customnode.css'; import ModalComponent from './ModalComponent'; import { Button } from './ui/button'; import { Input } from './ui/input'; -import { Textarea } from './ui/textarea'; type Schema = { type: string; @@ -442,6 +441,7 @@ const CustomNode: FC> = ({ data, id }) => { onClose={() => setIsModalOpen(false)} onSave={handleModalSave} value={modalValue} + key={activeKey} /> ); diff --git a/rnd/autogpt_builder/src/components/ModalComponent.tsx b/rnd/autogpt_builder/src/components/ModalComponent.tsx index 981b3a59a..79d714796 100644 --- a/rnd/autogpt_builder/src/components/ModalComponent.tsx +++ b/rnd/autogpt_builder/src/components/ModalComponent.tsx @@ -1,4 +1,4 @@ -import React, { FC } from 'react'; +import React, { FC, useEffect } from 'react'; import './modal.css'; import { Button } from './ui/button'; import { Textarea } from './ui/textarea'; @@ -13,6 +13,12 @@ interface ModalProps { const ModalComponent: FC = ({ isOpen, onClose, onSave, value }) => { const [tempValue, setTempValue] = React.useState(value); + useEffect(() => { + if (isOpen) { + setTempValue(value); + } + }, [isOpen, value]); + const handleSave = () => { onSave(tempValue); onClose();