You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a graph generate from a JSON, and I would like to allow the nodes to be moved, but block node creation/deletion and edge swap/creation/deletion.
The readOnly prop is almost what I need, but obviously I cannot change nodes' positions.
Is there a way to block all the actions except for nodes' updates (if not in readOnly mode) or to allow only nodes' updates (readOnly mode)
You can pass any function to the onUpdateNode callback or any other callbacks. You can even pass empty functions to prevent certain callbacks from affecting the data.
onUpdateNode={() => {
// do nothing or do very specific things like ignoring x/y updates.
}}
onDeleteNode={() => {}}
I finally solved by using a combination of readOnly mode and onSelectNode + onBackgroundClick.
Dealing with "editMode" and passing empty functions only resulted in more troubles, particularly with edges, since there is no way to completely handle the "lifecycle" of edges (e.g.: I had a problem of dangling edges while trying to block edge swaps).
It could be useful to add a way to freely move nodes in readOnly mode, maybe a drag-and-drop handler.
Thanks @riccardolocci. We would appreciate any PR that could help solve your issue. At this point since you have used other methods of solving this, I will close the issue.
You are welcome to reopen it if you can provide an example that could reproduce your issue so that we can help further.
Activity
ajbogh commentedon Jan 29, 2020
You can pass any function to the onUpdateNode callback or any other callbacks. You can even pass empty functions to prevent certain callbacks from affecting the data.
riccardolocci commentedon Feb 3, 2020
I finally solved by using a combination of
readOnlymode andonSelectNode+onBackgroundClick.Dealing with "
editMode" and passing empty functions only resulted in more troubles, particularly with edges, since there is no way to completely handle the "lifecycle" of edges (e.g.: I had a problem of dangling edges while trying to block edge swaps).It could be useful to add a way to freely move nodes in
readOnlymode, maybe a drag-and-drop handler.ajbogh commentedon Feb 4, 2020
Thanks @riccardolocci. We would appreciate any PR that could help solve your issue. At this point since you have used other methods of solving this, I will close the issue.
You are welcome to reopen it if you can provide an example that could reproduce your issue so that we can help further.