reaviz / reaflow

🎯 React library for building workflow editors, flow charts and diagrams. Maintained by @goodcodeus.
https://reaflow.dev
Apache License 2.0
2.02k stars 117 forks source link

onNodeLink is not called for linking multiple nested nodes #33

Open henrymgarrett opened 3 years ago

henrymgarrett commented 3 years ago

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Current behavior

onNodeLink is not called for children of nested nodes.

Slightly longer explanation: When I have two nested nodes, each with child nodes, and I try to draw an edge between child nodes of different parents (in the picture, Child 1.2 -> Child 2.1), onNodeLinkCheck is called, but onNodeLink never gets called. I have verified that I return true from onNodeLinkCheck for these two child nodes.

Expected behavior

The desired behavior is that no matter the nodes, if onNodeLinkCheck returns true, onNodeLink should be called

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

In my application, I only allow linking of parent nodes, so I need to be able to detect if a user is starting/completing an edge from anywhere in a nested node. Currently, the solution works if I do link dragging on the excess space between the child node border and inside of the nested parent border, but that is not intuitive to the user.

Environment


Libs:
- react version: 16.13.1
- realflow version: 2.4.4


Browser:
- [ x ] Chrome (desktop) version 86.0.4240.198

Others:
amcdnl commented 3 years ago

I believe this is the issue:

  const onDragEnd = () => {
    if (dragNode && enteredNode && canLinkNode && dragNode.parent !== enteredNode.id) {
      onNodeLink(dragNode, enteredNode, dragPort);
    }

Note the dragNode.parent !== enteredNode.id condition - i will remove this but need to do some testing first.

henrymgarrett commented 3 years ago

@amcdnl Thanks so much. Let me know when it is deployed and I will update my version 👍

amcdnl commented 3 years ago

done in latest.

henrymgarrett commented 3 years ago

@amcdnl Is the code you typed out above from one of the drag hooks? I updated to the latest, and am implementing dragging myself, but I do not get onNodeLink called even when I return true from onNodeLinkCheck