diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx index 0072136a3..020ab4bb4 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx @@ -2075,7 +2075,18 @@ const WorkflowContent = React.memo(() => { ...node, selected: pendingSet.has(node.id), })) - setDisplayNodes(resolveParentChildSelectionConflicts(withSelection, blocks)) + const resolved = resolveParentChildSelectionConflicts(withSelection, blocks) + setDisplayNodes(resolved) + const selectedIds = resolved.filter((node) => node.selected).map((node) => node.id) + const { currentBlockId, clearCurrentBlock, setCurrentBlockId } = + usePanelEditorStore.getState() + if (selectedIds.length === 1 && selectedIds[0] !== currentBlockId) { + setCurrentBlockId(selectedIds[0]) + } else if (selectedIds.length === 0 && currentBlockId) { + clearCurrentBlock() + } else if (selectedIds.length > 1 && currentBlockId) { + clearCurrentBlock() + } return } @@ -2181,6 +2192,8 @@ const WorkflowContent = React.memo(() => { setCurrentBlockId(selectedIds[0]) } else if (selectedIds.length === 0 && currentBlockId) { clearCurrentBlock() + } else if (selectedIds.length > 1 && currentBlockId) { + clearCurrentBlock() } } },