fix: expanding collapsed edges breaks existing edges#131
Conversation
| @@ -606,9 +609,12 @@ return { | |||
| edge.data('originalEnds', originalEndsData); | |||
| } | |||
|
|
|||
There was a problem hiding this comment.
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.
Added a "repairEdge" function that repairs meta links for edges after they have been expanded
| var children = node.data('collapsedChildren') || []; | ||
| for(let child of node.children()) { | ||
| collapsedChildren = this.getCollapsedChildrenRecursively(child, collapsedChildren); | ||
| } |
There was a problem hiding this comment.
collapsed children are also children who have collapsed children
| 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.
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