Hello! I've recently come across a bug where if nodes are first defined as having a parent node, and then in a subsequent render a) these nodes' 'parent' property are set to 'null' and b) the parent nodes themselves are removed from the 'elements' list, the Cytoscape component will remove both the parent and its children, whereas what I would expect is for the children to remain part of the graph but no longer attached to a parent. I am not very familiar with the underlying implementation, but I think what might be happening here is that the child nodes are not first moved (via eles.move()) to a null parent before the parent nodes themselves are removed (via eles.remove()), causing the unintentional deletion of the parents' child nodes. I can verify that the following implementation first removes deleted nodes before adding or patching nodes: https://github.com/plotly/react-cytoscapejs/blob/master/src/patch.js.
Here is an example implementation to illustrate the issue in a browser:
Hello! I've recently come across a bug where if nodes are first defined as having a parent node, and then in a subsequent render a) these nodes' 'parent' property are set to 'null' and b) the parent nodes themselves are removed from the 'elements' list, the Cytoscape component will remove both the parent and its children, whereas what I would expect is for the children to remain part of the graph but no longer attached to a parent. I am not very familiar with the underlying implementation, but I think what might be happening here is that the child nodes are not first moved (via eles.move()) to a null parent before the parent nodes themselves are removed (via eles.remove()), causing the unintentional deletion of the parents' child nodes. I can verify that the following implementation first removes deleted nodes before adding or patching nodes: https://github.com/plotly/react-cytoscapejs/blob/master/src/patch.js.
Here is an example implementation to illustrate the issue in a browser: