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:
5
.changeset/many-donkeys-train.md
Normal file
5
.changeset/many-donkeys-train.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@vue-flow/core": patch
|
||||
---
|
||||
|
||||
Remove edgelookup update when updating connection lookup as edge lookup is computed already
|
||||
@@ -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])
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user