Skip to content

Commit ee7a561

Browse files
committed
Merge branch 'fix/select' of github.com:simstudioai/sim into fix/select
2 parents 4fa6cb8 + 6e7f3da commit ee7a561

File tree

4 files changed

+227
-110
lines changed

4 files changed

+227
-110
lines changed

apps/sim/app/_styles/globals.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@
5151
border: 1px solid var(--brand-secondary) !important;
5252
}
5353

54-
.react-flow__nodesselection-rect {
54+
.react-flow__nodesselection-rect,
55+
.react-flow__nodesselection {
5556
background: transparent !important;
5657
border: none !important;
58+
pointer-events: none !important;
5759
}
5860

5961
/**

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export {
22
clearDragHighlights,
33
computeClampedPositionUpdates,
4+
computeParentUpdateEntries,
45
getClampedPositionForNode,
56
isInEditableElement,
67
selectNodesDeferred,

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

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Node } from 'reactflow'
1+
import type { Edge, Node } from 'reactflow'
22
import { BLOCK_DIMENSIONS, CONTAINER_DIMENSIONS } from '@/lib/workflows/blocks/block-dimensions'
33
import { TriggerUtils } from '@/lib/workflows/triggers/triggers'
44
import { clampPositionToContainer } from '@/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-node-utilities'
@@ -139,3 +139,43 @@ export function computeClampedPositionUpdates(
139139
position: getClampedPositionForNode(node.id, node.position, blocks, allNodes),
140140
}))
141141
}
142+
143+
interface ParentUpdateEntry {
144+
blockId: string
145+
newParentId: string
146+
affectedEdges: Edge[]
147+
}
148+
149+
/**
150+
* Computes parent update entries for nodes being moved into a subflow.
151+
* Only includes "boundary edges" - edges that cross the selection boundary
152+
* (one end inside selection, one end outside). Edges between nodes in the
153+
* selection are preserved.
154+
*/
155+
export function computeParentUpdateEntries(
156+
validNodes: Node[],
157+
allEdges: Edge[],
158+
targetParentId: string
159+
): ParentUpdateEntry[] {
160+
const movingNodeIds = new Set(validNodes.map((n) => n.id))
161+
162+
// Find edges that cross the boundary (one end inside selection, one end outside)
163+
// Edges between nodes in the selection should stay intact
164+
const boundaryEdges = allEdges.filter((e) => {
165+
const sourceInSelection = movingNodeIds.has(e.source)
166+
const targetInSelection = movingNodeIds.has(e.target)
167+
// Only remove if exactly one end is in the selection (crosses boundary)
168+
return sourceInSelection !== targetInSelection
169+
})
170+
171+
// Build updates for all valid nodes
172+
return validNodes.map((n) => {
173+
// Only include boundary edges connected to this specific node
174+
const edgesForThisNode = boundaryEdges.filter((e) => e.source === n.id || e.target === n.id)
175+
return {
176+
blockId: n.id,
177+
newParentId: targetParentId,
178+
affectedEdges: edgesForThisNode,
179+
}
180+
})
181+
}

0 commit comments

Comments
 (0)