-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: expanding collapsed edges breaks existing edges #131
base: master
Are you sure you want to change the base?
Conversation
@@ -606,9 +609,12 @@ return { | |||
edge.data('originalEnds', originalEndsData); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this improves readability and inverses the condition
this.repairEdgesForNode(edge.source()); | ||
this.repairEdgesForNode(edge.target()); | ||
}, | ||
repairEdgesForNode: function(node) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a "repairEdge" function that repairs meta links for edges after they have been expanded
@@ -670,6 +684,10 @@ return { | |||
*/ | |||
getCollapsedChildrenRecursively: function(node, collapsedChildren){ | |||
var children = node.data('collapsedChildren') || []; | |||
for(let child of node.children()) { | |||
collapsedChildren = this.getCollapsedChildrenRecursively(child, collapsedChildren); | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
collapsed children are also children who have collapsed children
@@ -783,7 +801,33 @@ return { | |||
edge.trigger('expandcollapse.beforeexpandedge'); | |||
result.oldEdges = result.oldEdges.add(edge); | |||
cy.remove(edge); | |||
result.edges = cy.add(edges); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the main fix:
- added try / catch to avoid breaking everything in case of an exception
- before adding the new edges (after expanding a collapsed edge) verify that their source/target are visible
- If source or target not visible treat the edge as a meta edge
- save original ends
- add meta edge class
- instead of "move" just update source and data - move will fail since its source or target is missing
- After everything call "repairEdge" to properly re-link all meta edges
Your PR does not seem to fix this issue, but the master banch on your fork does. What's up with that? |
Your fork was working perfectly, until I came across this issue when I try to collapse a compound node with a lot of nodes: This node actually exists in the input data |
Hello, @Revadike it is because there are a couple of fixes and the repository maintainers do not wish to merge them. On my fork I have merged both to the master branch. Regarding your other issue I can't tell where it may be coming from. You should create a minimal example that reproduces it. P.S Yes it is frustrating when things do not work but please have in mind that this is a open source collaboration and everyone of us contributes in terms of their availability and motivation. Please try contributing as well ! :) |
This PR fixes issues described in #128 where expanding / collapsing edges can lead to an exception and a loss of edges between nodes.
Second issue was that collapsing / expanding nodes with collapsed edges would result into a bad "repair" of the original link's source and destination