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();