Use local state for input loop value (#1484)

This commit is contained in:
Shuchang Zheng
2025-01-04 03:09:25 -08:00
committed by GitHub
parent 1d49dadca3
commit 0a8f1a824e

View File

@@ -18,6 +18,7 @@ import { EditableNodeTitle } from "../components/EditableNodeTitle";
import { NodeActionMenu } from "../NodeActionMenu";
import { WorkflowBlockIcon } from "../WorkflowBlockIcon";
import type { LoopNode } from "./types";
import { useState } from "react";
function LoopNode({ id, data }: NodeProps<LoopNode>) {
const { updateNodeData } = useReactFlow();
@@ -26,6 +27,9 @@ function LoopNode({ id, data }: NodeProps<LoopNode>) {
id,
initialValue: data.label,
});
const [inputs, setInputs] = useState({
loopValue: data.loopValue,
});
const deleteNodeCallback = useDeleteNodeCallback();
const children = nodes.filter((node) => node.parentId === id);
@@ -101,8 +105,12 @@ function LoopNode({ id, data }: NodeProps<LoopNode>) {
</div>
<WorkflowBlockInput
nodeId={id}
value={data.loopValue}
value={inputs.loopValue}
onChange={(value) => {
setInputs({
...inputs,
loopValue: value,
});
updateNodeData(id, { loopValue: value });
}}
/>