Skip to content

Commit 28943eb

Browse files
committed
ack PR comments
1 parent 5e1c838 commit 28943eb

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/utils/workflow-canvas-helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export function resolveParentChildSelectionConflicts(
202202
let hasConflict = false
203203
const resolved = nodes.map((n) => {
204204
if (!n.selected) return n
205-
const parentId = n.parentId || n.data?.parentId || blocks[n.id]?.data?.parentId
205+
const parentId = n.parentId || blocks[n.id]?.data?.parentId
206206
if (parentId && selectedIds.has(parentId)) {
207207
hasConflict = true
208208
return { ...n, selected: false }

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2047,9 +2047,7 @@ const WorkflowContent = React.memo(() => {
20472047
(changes: NodeChange[]) => {
20482048
setDisplayNodes((nds) => {
20492049
const updated = applyNodeChanges(changes, nds)
2050-
const hasSelectionChange = changes.some(
2051-
(c) => c.type === 'select' && (c as { selected?: boolean }).selected
2052-
)
2050+
const hasSelectionChange = changes.some((c) => c.type === 'select')
20532051
return hasSelectionChange ? resolveParentChildSelectionConflicts(updated, blocks) : updated
20542052
})
20552053
},
@@ -2857,16 +2855,14 @@ const WorkflowContent = React.memo(() => {
28572855
setDragStartParentId(firstNodeParentId)
28582856
}
28592857

2860-
// Resolve parent-child conflicts and capture positions for undo/redo
2861-
setDisplayNodes((allNodes) => resolveParentChildSelectionConflicts(allNodes, blocks))
2862-
28632858
// Filter to nodes that won't be deselected (exclude children whose parent is selected)
28642859
const nodeIds = new Set(nodes.map((n) => n.id))
28652860
const effectiveNodes = nodes.filter((n) => {
28662861
const parentId = blocks[n.id]?.data?.parentId
28672862
return !parentId || !nodeIds.has(parentId)
28682863
})
28692864

2865+
// Capture positions for undo/redo before applying display changes
28702866
multiNodeDragStartRef.current.clear()
28712867
effectiveNodes.forEach((n) => {
28722868
const blk = blocks[n.id]
@@ -2878,6 +2874,9 @@ const WorkflowContent = React.memo(() => {
28782874
})
28792875
}
28802876
})
2877+
2878+
// Apply visual deselection of children
2879+
setDisplayNodes((allNodes) => resolveParentChildSelectionConflicts(allNodes, blocks))
28812880
},
28822881
[blocks]
28832882
)

0 commit comments

Comments
 (0)