fix(core): remove edge lookup update when updating connection lookup

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>

* chore(changeset): add

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>

---------

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
Braks
2025-03-14 15:26:58 +01:00
parent b85b0ec66f
commit 05e4df2cb6
3 changed files with 13 additions and 5 deletions

View File

@@ -0,0 +1,5 @@
---
"@vue-flow/core": patch
---
Remove edgelookup update when updating connection lookup as edge lookup is computed already

View File

@@ -509,7 +509,13 @@ export function useActions(state: State, nodeLookup: ComputedRef<NodeLookup>, ed
}
const updateEdge: Actions['updateEdge'] = (oldEdge, newConnection, shouldReplaceId = true) => {
const prevEdge = findEdge(oldEdge.id)!
const prevEdge = findEdge(oldEdge.id)
if (!prevEdge) {
return false
}
const prevEdgeIndex = state.edges.indexOf(prevEdge)
const newEdge = updateEdgeAction(oldEdge, newConnection, prevEdge, shouldReplaceId, state.hooks.error.trigger)
@@ -525,7 +531,7 @@ export function useActions(state: State, nodeLookup: ComputedRef<NodeLookup>, ed
state.edges,
)
state.edges.splice(state.edges.indexOf(prevEdge), 1, validEdge)
state.edges = state.edges.map((edge, index) => (index === prevEdgeIndex ? validEdge : edge))
updateConnectionLookup(state.connectionLookup, edgeLookup.value, [validEdge])

View File

@@ -165,7 +165,6 @@ function addConnectionToLookup(
export function updateConnectionLookup(connectionLookup: ConnectionLookup, edgeLookup: EdgeLookup, edges: GraphEdge[]) {
connectionLookup.clear()
edgeLookup.clear()
for (const edge of edges) {
const { source: sourceNode, target: targetNode, sourceHandle = null, targetHandle = null } = edge
@@ -176,8 +175,6 @@ export function updateConnectionLookup(connectionLookup: ConnectionLookup, edgeL
addConnectionToLookup('source', connection, targetKey, connectionLookup, sourceNode, sourceHandle)
addConnectionToLookup('target', connection, sourceKey, connectionLookup, targetNode, targetHandle)
edgeLookup.set(edge.id, edge)
}
}