diff --git a/app/src/components/SimulationDashboard/components/element/ElementEditor.tsx b/app/src/components/SimulationDashboard/components/element/ElementEditor.tsx index 1802ffa..354d9ea 100644 --- a/app/src/components/SimulationDashboard/components/element/ElementEditor.tsx +++ b/app/src/components/SimulationDashboard/components/element/ElementEditor.tsx @@ -56,13 +56,19 @@ const ElementEditor: React.FC = ({ const { getElementById } = simulationDashBoardStore(); const element = getElementById(selectedBlock, selectedElement); const [selectType, setSelectType] = useState("design"); - const [selectDataMapping, setSelectDataMapping] = useState<"singleMachine" | "multipleMachine" | "global">( - element?.type === "graph" && element.dataBinding?.dataType === "multiple-machine" - ? "multipleMachine" - : element?.type === "graph" && element.dataBinding?.dataType === "global" - ? "global" - : "singleMachine" - ); + const [selectDataMapping, setSelectDataMapping] = useState<"singleMachine" | "multipleMachine" | "global">("singleMachine"); + + useEffect(() => { + if (element?.type === "graph") { + if (element.dataBinding?.dataType === "multiple-machine") { + setSelectDataMapping("multipleMachine"); + } else if (element.dataBinding?.dataType === "global") { + setSelectDataMapping("global"); + } else { + setSelectDataMapping("singleMachine"); + } + } + }, [element?.elementUuid, element?.dataBinding?.dataType, element?.type]); // Use shared position from VisualizationStore const { editorPosition, setEditorPosition } = useVisualizationStore();