Skip to content

fix: KEEP-288 guard onConnectEnd node creation with connectionState.isValid#905

Merged
suisuss merged 1 commit intostagingfrom
fix/KEEP-288-node-created-on-connect
Apr 21, 2026
Merged

fix: KEEP-288 guard onConnectEnd node creation with connectionState.isValid#905
suisuss merged 1 commit intostagingfrom
fix/KEEP-288-node-created-on-connect

Conversation

@suisuss
Copy link
Copy Markdown

@suisuss suisuss commented Apr 21, 2026

Summary

In the workflow canvas, dragging a connection from one node's handle to another node's handle successfully created the edge and spawned a spurious extra node with its own spurious edge.

Root cause: onConnectEnd used a DOM hit-test (event.target.closest('.react-flow__node' | '.react-flow__handle')) to decide whether the drop landed on empty pane. During an xyflow connection drag, event.target on mouseup can be the connection-line SVG overlay rather than the target handle, so the pane-drop branch fired even on successful handle-to-handle drops -- creating a node in addition to the edge that onConnect already made.

Fix: replace the DOM hit-test with xyflow's own FinalConnectionState.isValid. Only isValid === null (pointer never entered a handle's connection radius) is treated as a true pane drop.

  • true: valid connection -- onConnect handled it, skip.
  • false: over an invalid handle -- skip (preserves prior behavior where the DOM check also skipped).
  • null: genuine pane drop -- create fallback node + edge.

File touched: components/workflow/workflow-canvas.tsx.

Test plan

  • Drag from one node's handle to another node's handle -> only one edge is created, no extra node.
  • Drag from a handle to empty canvas -> new action node is created and auto-connected (existing pane-drop feature preserved).
  • Drop on an invalid handle (e.g. source-to-source) -> nothing happens.
  • For Each / Condition connection auto-handle assignment still works (unchanged path).

…sValid

The DOM-based hit-test (event.target.closest('.react-flow__node'|'.react-flow__handle'))
is unreliable on mouseup during an xyflow connection drag. event.target can be the
connection-line overlay rather than the target handle, so a successful handle-to-handle
drop fired both onConnect (correct edge) and onConnectEnd's fallback "create node on
pane drop" branch (spurious node + spurious edge).

Replace the DOM check with xyflow's own tri-state signal: FinalConnectionState.isValid.
Only null (pointer never entered a handle's connection radius) represents a true pane
drop. true means onConnect already handled it; false means an invalid handle drop.
@suisuss suisuss merged commit aa1cb9e into staging Apr 21, 2026
27 checks passed
@suisuss suisuss deleted the fix/KEEP-288-node-created-on-connect branch April 21, 2026 03:36
@github-actions
Copy link
Copy Markdown

🧹 PR Environment Cleaned Up

The PR environment has been successfully deleted.

Deleted Resources:

  • Namespace: pr-905
  • All Helm releases (Keeperhub, Scheduler, Event services)
  • PostgreSQL Database (including data)
  • LocalStack, Redis
  • All associated secrets and configs

All resources have been cleaned up and will no longer incur costs.

@github-actions
Copy link
Copy Markdown

ℹ️ No PR Environment to Clean Up

No PR environment was found for this PR. This is expected if:

  • The PR never had the deploy-pr-environment label
  • The environment was already cleaned up
  • The deployment never completed successfully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant