fix(core): unwrap nodesConnectable in onClick of handle
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -64,8 +64,8 @@ export default function useHandle({
|
|||||||
|
|
||||||
let isValidConnectionHandler = isValidConnection || isValidConnectionProp.value || alwaysValid
|
let isValidConnectionHandler = isValidConnection || isValidConnectionProp.value || alwaysValid
|
||||||
|
|
||||||
if (!isValidConnectionHandler) {
|
if (!isValidConnectionHandler && node) {
|
||||||
if (node) isValidConnectionHandler = (!isTarget ? node.isValidTargetPos : node.isValidSourcePos) || alwaysValid
|
isValidConnectionHandler = (!isTarget ? node.isValidTargetPos : node.isValidSourcePos) || alwaysValid
|
||||||
}
|
}
|
||||||
|
|
||||||
let prevClosestHandle: ConnectionHandle | null
|
let prevClosestHandle: ConnectionHandle | null
|
||||||
@@ -97,6 +97,7 @@ export default function useHandle({
|
|||||||
if (!autoPanOnConnect) {
|
if (!autoPanOnConnect) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const [xMovement, yMovement] = calcAutoPan(connectionPosition, containerBounds)
|
const [xMovement, yMovement] = calcAutoPan(connectionPosition, containerBounds)
|
||||||
|
|
||||||
panBy({ x: xMovement, y: yMovement })
|
panBy({ x: xMovement, y: yMovement })
|
||||||
@@ -163,7 +164,9 @@ export default function useHandle({
|
|||||||
getConnectionStatus(!!prevClosestHandle, isValid),
|
getConnectionStatus(!!prevClosestHandle, isValid),
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!prevClosestHandle && !isValid && !handleDomNode) return resetRecentHandle(prevActiveHandle)
|
if (!prevClosestHandle && !isValid && !handleDomNode) {
|
||||||
|
return resetRecentHandle(prevActiveHandle)
|
||||||
|
}
|
||||||
|
|
||||||
if (connection && connection.source !== connection.target && handleDomNode) {
|
if (connection && connection.source !== connection.target && handleDomNode) {
|
||||||
resetRecentHandle(prevActiveHandle)
|
resetRecentHandle(prevActiveHandle)
|
||||||
@@ -179,16 +182,19 @@ export default function useHandle({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onPointerUp(event: MouseTouchEvent) {
|
function onPointerUp(event: MouseTouchEvent) {
|
||||||
if (prevClosestHandle || handleDomNode) {
|
if ((prevClosestHandle || handleDomNode) && connection && isValid) {
|
||||||
if (connection && isValid) {
|
if (!onEdgeUpdate) {
|
||||||
if (!onEdgeUpdate) emits.connect(connection)
|
emits.connect(connection)
|
||||||
else onEdgeUpdate(event, connection)
|
} else {
|
||||||
|
onEdgeUpdate(event, connection)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emits.connectEnd(event)
|
emits.connectEnd(event)
|
||||||
|
|
||||||
if (edgeUpdaterType) onEdgeUpdateEnd?.(event)
|
if (edgeUpdaterType) {
|
||||||
|
onEdgeUpdateEnd?.(event)
|
||||||
|
}
|
||||||
|
|
||||||
resetRecentHandle(prevActiveHandle)
|
resetRecentHandle(prevActiveHandle)
|
||||||
|
|
||||||
@@ -216,7 +222,9 @@ export default function useHandle({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleClick = (event: MouseEvent) => {
|
const handleClick = (event: MouseEvent) => {
|
||||||
if (!connectOnClick.value) return
|
if (!connectOnClick.value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (!connectionClickStartHandle.value) {
|
if (!connectionClickStartHandle.value) {
|
||||||
startConnection({ nodeId: unref(nodeId), type: unref(type), handleId: unref(handleId) }, undefined, event, true)
|
startConnection({ nodeId: unref(nodeId), type: unref(type), handleId: unref(handleId) }, undefined, event, true)
|
||||||
@@ -225,11 +233,13 @@ export default function useHandle({
|
|||||||
|
|
||||||
const node = findNode(unref(nodeId))
|
const node = findNode(unref(nodeId))
|
||||||
|
|
||||||
if (!isValidConnectionHandler) {
|
if (!isValidConnectionHandler && node) {
|
||||||
if (node) isValidConnectionHandler = (!isTarget ? node.isValidTargetPos : node.isValidSourcePos) || alwaysValid
|
isValidConnectionHandler = (!isTarget ? node.isValidTargetPos : node.isValidSourcePos) || alwaysValid
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node && (typeof node.connectable === 'undefined' ? nodesConnectable : node.connectable) === false) return
|
if (node && (typeof node.connectable === 'undefined' ? nodesConnectable.value : node.connectable) === false) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const doc = getHostForElement(event.target as HTMLElement)
|
const doc = getHostForElement(event.target as HTMLElement)
|
||||||
|
|
||||||
@@ -252,7 +262,9 @@ export default function useHandle({
|
|||||||
|
|
||||||
const isOwnHandle = connection.source === connection.target
|
const isOwnHandle = connection.source === connection.target
|
||||||
|
|
||||||
if (isValid && !isOwnHandle) emits.connect(connection)
|
if (isValid && !isOwnHandle) {
|
||||||
|
emits.connect(connection)
|
||||||
|
}
|
||||||
|
|
||||||
endConnection(event, true)
|
endConnection(event, true)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user