cytoscape.js-expand-collapse
cytoscape.js-expand-collapse copied to clipboard
expand(nodes, option) does not respect the passed options
Hi, I have observed, that the expand(nodes, options) function does not apply correctly the passed options, when called.
Reproduce the issue:
- Display the graph with a layout and specify this layout in the options object
layoutBy : {name: dagre}
field - Collapse all nodes and edges with
2.1.
collapseAll(options)
2.2.collapseAllEdges()
- Change the layoutBy field in the options object,
layoutBy : {name: breadthfirst}
- Expand any collapsed nodeA using
4.1.
expandEdgesBetweenNodes([nodeA, ...neighbors]))
4.2.expand(nodeA, options)
- Notice that the graph you see is still in the dagre layout.
When you use instead:
- ...
- Expand all collapsed nodes using
4.1.
expandAllEdges()
4.2.expandAll(options)
- Notice that the new layout has been applied.
Possible reason By having a quick look into your source code, I assume the problem results from these lines in the file: expandCollapseUtilities.js, function: expandNodeBaseFunction, lines 46 – 48:
if (single) { this.endOperation(layoutBy, node); }
In any other expand function, see expandAll(options)
, the nodes will always be rearranged by the endOperation after expanding. Here, the rearrangement is conditional, which may cause this bug.