question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Edges connect to wrong handles in ConnectionMode.Loose

See original GitHub issue

Describe the Bug

The problem occurs when ConnectionMode.Loose is used and nodes have target as well as source nodes. Once two sources get connected, the edge is displayed as connected to the target handle of the target node, despite specifying the source handle correctly in the edge data.

Just having a quick glance at the source code, I believe the following lines to cause the problem: https://github.com/wbkd/react-flow/blob/6526e3297e67c57c2e9be0654be3792c6cc04483/packages/core/src/container/EdgeRenderer/index.tsx#L116-L121 target handles exist, so the source handles array gets disregarded. getHandle then chooses the first target, because it’s the only one available (at least in my case it is). Maybe a .concat instead of || would fix this.

Your Example Website or App

https://github.com/michaelspiss/berry-sethi-tutor

Steps to Reproduce the Bug or Issue

  • Have a react flow with connectionMode={ConnectionMode.Loose}.
  • Have two default nodes in the graph
  • Connect source to source -> will display as source to target, despite being source to source in the data

Expected behavior

Edge should connect to handle specified in its data

Screenshots or Videos

s: source handle, t: target handle (visibility: hidden here). Windows screen recorder messed up the pointer position a bit, just assume it’s on point.

https://user-images.githubusercontent.com/17252710/205444554-557faa6d-9b2d-4dee-9fb0-c6021cf67a74.mp4

Platform

  • OS: all
  • Browser: all
  • Version: 11.3.2

Additional context

No response

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
bcakmakoglucommented, Dec 8, 2022

Ok 😃 It was just an idea 😅

1reaction
moklickcommented, Dec 5, 2022

Thanks @michaelspiss I’ll check this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Edge Removal Improvements · Issue #943 · wbkd/react-flow
Select the edge and press the "deleteKeyCode" key · Use connectionMode="loose" and remove an edge when dragging it on itself.
Read more >
Props List API
Called when user connects two nodes in a controlled flow ... Edges get a higher zIndex if this is true and a connected...
Read more >
React flow selecting top edge selects bottom edge
If all handles are sources you also need to set connectionMode="loose" in order to connect sources with sources.".
Read more >
Configuration | Vue Flow
Type: ConnectionMode. Default: ConnectionMode.Loose. Details: If set to loose all handles are treated as source handles (thus allowing for connections on ...
Read more >
How to get the source and target handles in React Flow 10
This auto-connect should add an edge from each un-connected handle to the “end node”. If you want to add an edge in React...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found