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'm experiencing an issue with removing dynamic handles from my custom nodes. Whenever I remove a handle from a node that is already connected, it throws an error, as shown in the screenshot below:
This error seems to occur because the handle is missing, which disrupts the connection. Ideally, I would expect the edge to be removed automatically when the handle it’s connected to is missing.
The more I look into it the more messy solutiuons come to my mind but maybe i'm missing some crucial informations.
Current Implementation
My handles are dynamically rendered based on an array of handles in node.data. Users can add or remove handles via a separate form, which doesn’t directly add, edit, or remove handles but instead submits an updated array of handles. When this updated array is passed to the node, any removed handles are simply omitted.
Because of this setup, I don’t have a specific handleId to target for removal; rather, I just have a new array passed to the node.
Attempted Solution
I found a related issue here: Discussion #3123 on xyflow. Based on this, I tried a solution that filters out edges without matching source or target handles in the updated nodes.
While this works, it feels inefficient, as it repeatedly checks all nodes and handles. I'm seeking a cleaner, more efficient way to automatically remove edges when handles are missing.
Any insights or suggestions on how to improve this logic would be greatly appreciated!
##Edit
I have moved this function from useEffect to 'changeNode' func so it triggers only on form save isntead of every node change.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm experiencing an issue with removing dynamic handles from my custom nodes. Whenever I remove a handle from a node that is already connected, it throws an error, as shown in the screenshot below:
This error seems to occur because the handle is missing, which disrupts the connection. Ideally, I would expect the edge to be removed automatically when the handle it’s connected to is missing.
The more I look into it the more messy solutiuons come to my mind but maybe i'm missing some crucial informations.
Current Implementation
My handles are dynamically rendered based on an array of handles in
node.data. Users can add or remove handles via a separate form, which doesn’t directly add, edit, or remove handles but instead submits an updated array of handles. When this updated array is passed to the node, any removed handles are simply omitted.Because of this setup, I don’t have a specific
handleIdto target for removal; rather, I just have a new array passed to the node.Attempted Solution
I found a related issue here: Discussion #3123 on xyflow. Based on this, I tried a solution that filters out edges without matching source or target handles in the updated nodes.
Here’s my current approach:
While this works, it feels inefficient, as it repeatedly checks all nodes and handles. I'm seeking a cleaner, more efficient way to automatically remove edges when handles are missing.
Any insights or suggestions on how to improve this logic would be greatly appreciated!
##Edit
I have moved this function from useEffect to 'changeNode' func so it triggers only on form save isntead of every node change.
Beta Was this translation helpful? Give feedback.
All reactions