-
Notifications
You must be signed in to change notification settings - Fork 231
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
Node does not move/update when given coordinates or new coordinates #295
Comments
I see the issue is because the X and Y coordinates are in this white list: https://github.com/danielcaldas/react-d3-graph/blob/master/src/components/graph/graph.helper.js#L36 @danielcaldas is there any harm if we remove the X and Y coordinates from this whitelist? |
Safer would be to conditionaly skip the restore of On the other hand we could just do a dirty checking agains the Something along these lines... nodes: data.nodes.map(n => {
let { x, y } = state.nodes[n.id];
const node = state.nodes[n.id] ? { ...n, ...pick(state.nodes[n.id], NODE_PROPS_WHITELIST) } : { ...n };
const { x: clientX , y: clientY } = n;
if (clientX) {
node.x = clientX;
}
if (clientY) {
node.y = clientY;
}
return node;
} I have currently no time to look at it, would you be up to giving it a try and submit a PR @Kav91 ? Will scale priority according to the number of requests for this. |
This would be very useful! |
I've run into this as well; when a user moves a node around, the new position is persisted behind-the-scenes. I also have undo/redo functionality and undo-ing a node's movement doesn't properly update the graph. |
Being able to easily pass custom NODE_PROPS_WHITELIST would be helpful enough for me. |
Describe the bug
If a node is on the map already, and it is given a X or Y coordinate, it will not update to its new location. Likewise if it already had an X/Y coordinate, and received new coordinates it will not update.
If you update the name of the Node however, it will update.
To Reproduce
Use the sandbox, generate a node, give it an x and/or y coordinate and save it.
It will not move to its new location, it will only move if the id attribute is updated as it thinks it is a new node most likely.
Expected behavior
When a node is given coordinates or new coordinates it should update and move into the appropriate location
The text was updated successfully, but these errors were encountered: