diff --git a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx index 82a667c5a..c61cadc2b 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/parameterComponent/index.tsx @@ -80,7 +80,9 @@ export default function ParameterComponent({ const { data: myData } = useContext(typesContext); - const handleOnNewValue = (newValue: string | string[] | boolean): void => { + const handleOnNewValue = ( + newValue: string | string[] | boolean | Object[] + ): void => { let newData = cloneDeep(data); newData.node!.template[name].value = newValue; setData(newData); @@ -99,22 +101,7 @@ export default function ParameterComponent({ renderTooltips(); }; - const [obj, setObj] = useState({ - arr: ["test", 123456, false, null], - boolean: false, - number: 123456, - try: { - k1: 123, - k2: "123", - k3: false, - }, - string: "string", - }); - const [errorDuplicateKey, setErrorDuplicateKey] = useState(false); - const [dictArr, setDictArr] = useState([ - { yourKey: "yourValue" }, - ] as Object[]); useEffect(() => { if (name === "openai_api_base") console.log(info); @@ -237,6 +224,8 @@ export default function ParameterComponent({ type === "code" || type === "prompt" || type === "file" || + type === "dict" || + type === "NestedDict" || type === "int") && !optionalHandle ? ( <> @@ -378,10 +367,22 @@ export default function ParameterComponent({ { - setObj(newValue); data.node!.template[name].value = newValue; + handleOnNewValue(newValue); }} /> @@ -393,14 +394,14 @@ export default function ParameterComponent({ value={ data.node!.template[name].value?.length === 0 || !data.node!.template[name].value - ? dictArr + ? [{ yourKey: "yourValue" }] : convertObjToArray(data.node!.template[name].value) } duplicateKey={errorDuplicateKey} onChange={(newValue) => { - setErrorDuplicateKey(hasDuplicateKeys(newValue)); - setDictArr(newValue); data.node!.template[name].value = newValue; + setErrorDuplicateKey(hasDuplicateKeys(newValue)); + handleOnNewValue(newValue); }} /> diff --git a/src/frontend/src/components/dictComponent/index.tsx b/src/frontend/src/components/dictComponent/index.tsx index fd55430bb..981372506 100644 --- a/src/frontend/src/components/dictComponent/index.tsx +++ b/src/frontend/src/components/dictComponent/index.tsx @@ -17,6 +17,10 @@ export default function DictComponent({ } }, [disabled]); + useEffect(() => { + if (value) onChange(value); + }, [value]); + return (
{ + if (value) onChange(value); + }, [value]); + return (
( -
+
{children}
@@ -27,7 +27,7 @@ const DialogOverlay = React.forwardRef<