Skip to content
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

Some properties make the graph becomes unresetable #372

Closed
antoninklopp opened this issue Sep 12, 2020 · 1 comment · Fixed by #377
Closed

Some properties make the graph becomes unresetable #372

antoninklopp opened this issue Sep 12, 2020 · 1 comment · Fixed by #377
Labels

Comments

@antoninklopp
Copy link
Collaborator

Describe the bug
Some properties make the graph becomes unresetable.

To Reproduce
Steps to reproduce the behaviour:

  1. Go to sandbox 1, move nodes around and then click on Unstick nodes. Nodes are going back to their initial positions.
  2. Go to sandbox 2, move nodes around and then click on Unstick nodes. Nodes are not going back to their initial positions.

Expected behaviour
Given this code :

resetNodesPositions = () => this.refs.graph.resetNodesPositions();

it would make sense that it resets any graph to its initial position especially for static graphs which are not reset either.

Environment:

  • react-d3-graph version 2.5.0
@antoninklopp antoninklopp changed the title Static graph with drag and drop is not resetable Some properties make the graph becomes unresetable Sep 13, 2020
@danielcaldas
Copy link
Owner

At a first glance, there's seems to be something off with the implementation of resetNodesPositions. Initially, it was meant to not allow "reset" for static graphs, as we can clearly see by the if statement. But later on, we did not follow up with the staticGraphWithDragAndDrop property 🤔 . If someone if trying to look into this issue try to debug with the following:

  1. Understand how resetNodesPositions can be used from the client, make sure you can replicate the issues that @antoninklopp mentions in the issue description.
  2. Try to understand why is that the code, does not have an effect in the sandbox 2:
if (node.fx && node.fy) {
  Reflect.deleteProperty(node, "fx");
  Reflect.deleteProperty(node, "fy");
}
  1. I have a strong feeling that the issue might be around graph.helper.js in the function _initializeNodes(graphNodes) where we're looking into the properties fx and fy of node. But this is just a theory as of right now, I didn't have the time to look into this one yet, so if you're looking for a way to contribute, please go ahead, PRs are very welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants