cytoscape.js-expand-collapse icon indicating copy to clipboard operation
cytoscape.js-expand-collapse copied to clipboard

expand(nodes, option) does not respect the passed options

Open OskarHowe opened this issue 2 years ago • 0 comments

Hi, I have observed, that the expand(nodes, options) function does not apply correctly the passed options, when called.

Reproduce the issue:

  1. Display the graph with a layout and specify this layout in the options object layoutBy : {name: dagre} field
  2. Collapse all nodes and edges with 2.1. collapseAll(options) 2.2. collapseAllEdges()
  3. Change the layoutBy field in the options object, layoutBy : {name: breadthfirst}
  4. Expand any collapsed nodeA using 4.1. expandEdgesBetweenNodes([nodeA, ...neighbors])) 4.2. expand(nodeA, options)
  5. Notice that the graph you see is still in the dagre layout.

When you use instead:

  1. ...
  2. Expand all collapsed nodes using 4.1. expandAllEdges() 4.2. expandAll(options)
  3. 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.

OskarHowe avatar Aug 11 '22 12:08 OskarHowe