improvement(workflow): use DOM hit-testing for edge drop-on-block detection#3851
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview This removes reliance on flow-coordinate rectangle intersection logic (and its corner/precision issues) and updates Written by Cursor Bugbot for commit 7036307. Configure here. |
Greptile SummaryThis PR fixes a bug where dropping an edge onto the bottom-left or bottom-right corners of a workflow block would fail to register a connection. The fix replaces the geometry-based Key changes:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant ReactFlow
participant onConnectEnd
participant findNodeAtScreenPosition
participant DOM
User->>ReactFlow: Drag and drop edge
ReactFlow->>onConnectEnd: fires onConnectEnd(event)
onConnectEnd->>onConnectEnd: Check connectionCompletedRef<br/>(skip if handle-to-handle already handled)
onConnectEnd->>onConnectEnd: Extract clientX/clientY from event<br/>(handles MouseEvent & TouchEvent)
onConnectEnd->>findNodeAtScreenPosition: findNodeAtScreenPosition(clientX, clientY)
findNodeAtScreenPosition->>DOM: document.elementsFromPoint(clientX, clientY)
DOM-->>findNodeAtScreenPosition: elements[] (topmost → bottommost)
loop for each element
findNodeAtScreenPosition->>DOM: el.closest('.react-flow__node')
DOM-->>findNodeAtScreenPosition: nodeEl (HTMLElement | null)
findNodeAtScreenPosition->>findNodeAtScreenPosition: nodeEl.getAttribute('data-id')
findNodeAtScreenPosition->>findNodeAtScreenPosition: nodes.find(n => n.id === nodeId)
alt node found and not subflowNode
findNodeAtScreenPosition-->>onConnectEnd: return node
else skip
findNodeAtScreenPosition->>findNodeAtScreenPosition: continue
end
end
findNodeAtScreenPosition-->>onConnectEnd: undefined (no valid node found)
onConnectEnd->>onConnectEnd: targetNode.id !== source.nodeId?
onConnectEnd->>ReactFlow: onConnect({ source, sourceHandle, target, targetHandle })
Reviews (1): Last reviewed commit: "improvement(workflow): use DOM hit-testi..." | Re-trigger Greptile |
Summary
getIntersectingNodeswithdocument.elementsFromPoint()for detecting which block an edge is dropped onType of Change
Testing
Tested manually
Checklist