fix(core): use valid handle result as connecting handle (#1932)
* fix(core): use valid handle result as connecting handle Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com> * chore(changeset): add --------- Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
5
.changeset/orange-ligers-fail.md
Normal file
5
.changeset/orange-ligers-fail.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@vue-flow/core": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Use toHandle from valid handle check as target handle in ongoing connections
|
||||||
@@ -207,6 +207,7 @@ export function useHandle({
|
|||||||
edges.value,
|
edges.value,
|
||||||
nodes.value,
|
nodes.value,
|
||||||
findNode,
|
findNode,
|
||||||
|
nodeLookup.value,
|
||||||
)
|
)
|
||||||
|
|
||||||
handleDomNode = result.handleDomNode
|
handleDomNode = result.handleDomNode
|
||||||
@@ -242,18 +243,19 @@ export function useHandle({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const connectingHandle = closestHandle ?? result.toHandle
|
||||||
updateConnection(
|
updateConnection(
|
||||||
closestHandle && isValid
|
connectingHandle && isValid
|
||||||
? rendererPointToPoint(
|
? rendererPointToPoint(
|
||||||
{
|
{
|
||||||
x: closestHandle.x,
|
x: connectingHandle.x,
|
||||||
y: closestHandle.y,
|
y: connectingHandle.y,
|
||||||
},
|
},
|
||||||
viewport.value,
|
viewport.value,
|
||||||
)
|
)
|
||||||
: connectionPosition,
|
: connectionPosition,
|
||||||
result.toHandle,
|
result.toHandle,
|
||||||
getConnectionStatus(!!closestHandle, isValid),
|
getConnectionStatus(!!connectingHandle, isValid),
|
||||||
)
|
)
|
||||||
|
|
||||||
previousConnection = newConnection
|
previousConnection = newConnection
|
||||||
@@ -377,6 +379,7 @@ export function useHandle({
|
|||||||
edges.value,
|
edges.value,
|
||||||
nodes.value,
|
nodes.value,
|
||||||
findNode,
|
findNode,
|
||||||
|
nodeLookup.value,
|
||||||
)
|
)
|
||||||
|
|
||||||
const isOwnHandle = result.connection?.source === result.connection?.target
|
const isOwnHandle = result.connection?.source === result.connection?.target
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ export function getClosestHandle(
|
|||||||
const { x, y } = getHandlePosition(node, handle, handle.position, true)
|
const { x, y } = getHandlePosition(node, handle, handle.position, true)
|
||||||
|
|
||||||
const distance = Math.sqrt((x - position.x) ** 2 + (y - position.y) ** 2)
|
const distance = Math.sqrt((x - position.x) ** 2 + (y - position.y) ** 2)
|
||||||
|
|
||||||
if (distance > connectionRadius) {
|
if (distance > connectionRadius) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -139,6 +140,7 @@ export function isValidHandle(
|
|||||||
edges: GraphEdge[],
|
edges: GraphEdge[],
|
||||||
nodes: GraphNode[],
|
nodes: GraphNode[],
|
||||||
findNode: Actions['findNode'],
|
findNode: Actions['findNode'],
|
||||||
|
nodeLookup: NodeLookup,
|
||||||
) {
|
) {
|
||||||
const isTarget = fromType === 'target'
|
const isTarget = fromType === 'target'
|
||||||
const handleDomNode = handle
|
const handleDomNode = handle
|
||||||
@@ -195,7 +197,7 @@ export function isValidHandle(
|
|||||||
targetNode: findNode(connection.target)!,
|
targetNode: findNode(connection.target)!,
|
||||||
})
|
})
|
||||||
|
|
||||||
result.toHandle = handle
|
result.toHandle = getHandle(handleNodeId, handleType, handleId, nodeLookup, connectionMode, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user