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
useUpdateNodeInternals doesn't update edges after moving handles #2008
Comments
do you have animations when moving the handles? |
I don't animate the position of anything in my graph. I have some css animations which animate the opacity of drop shadows and border colors when dragging connection lines to indicate which targets are droppable, but I don't think that's what you mean |
having same problem with repositioning edge when node's size is chaning |
This might be a regression. I had the same problem (putting all edges into the middle) with a 9.x version, changing the version to |
did you solved? |
Did you try to add |
Could you try to use v10.3.15 ? It should work better now. |
I have a similar problem trying to delete orphans edges dynamically, my handles are dependent of values in fields, so I need to delete the edges when the fields are updated and the handles removed. This is weird, inside a custom node I try this:
The first log print the updated state of the handleBounds (inspecting the node in the tree map), but the second print the node with the old state. Using the setTimeout suggested by @AndrewRayCode works, so I can get the updated handleBounds and remove the edges:
And in my field changes handle something like this:
Regards |
Describe the Bug
I move my component handles around dynamically. The edges to those handles don't move, and any additional attempt to connect edges to the moved handles fails, the edges get connected to the wrong place. I'm using
useUpdateNodeInternals
but it doesn't work as I would expect.Your Example Website or App
No response
Steps to Reproduce the Bug or Issue
I have a custom handle component like this:
this is to try to force the edges to update correctly after I move handles around. I render it like this:
Expected behavior
In this case the effect fires, but the edge does not get moved to the right place. The edge stays stuck to the stale handle even after the handles update and the effect runs.
Sadly, this works:
the settimeout indicates to me there's some state/updating issue going on.
Screenshots or Videos
No response
Platform
Mac Chrome 10.0.3
Additional context
Related to #916
Discord convo starts here https://discord.com/channels/771389069270712320/859774873500778517/956236629603926046
As a consumer of react-flow,
useUpdateNodeInternals
is the first part of the API I personally find "ugly" - it's an imperative manual user step and it's unclear when it should be fired, and this issue indicates to me it's exposing some state update ordering that the end consumer shouldn't have to worry about. Also this is not something obvious to google for, I didn't discover it in the docs myself, someone in discord pointed me to this API. Ideally updating handles would "just work" out of the box.The text was updated successfully, but these errors were encountered: