fix(core): check if handle is connectable

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
braks
2023-03-06 23:07:59 +01:00
committed by Braks
parent 66e210adf4
commit f83c87db08
2 changed files with 3 additions and 2 deletions
@@ -169,6 +169,7 @@ export default function useHandle({
// todo: remove `vue-flow__handle-connecting` in next major version
handleDomNode.classList.add('connecting', 'vue-flow__handle-connecting')
handleDomNode.classList.toggle('valid', isValid)
// todo: remove this in next major version
handleDomNode.classList.toggle('vue-flow__handle-valid', isValid)
}
}
+2 -2
View File
@@ -96,7 +96,7 @@ export function isValidHandle(
connection: { source: '', target: '', sourceHandle: null, targetHandle: null },
}
if (handleDomNode && handle) {
if (handleToCheck && handleDomNode && handle) {
const handleNodeId = handleDomNode.getAttribute('data-nodeid')
const handleId = handleDomNode.getAttribute('data-handleid')
@@ -111,7 +111,7 @@ export function isValidHandle(
// in strict mode we don't allow target to target or source to source connections
const isValid =
connectionMode === ConnectionMode.Strict
handleToCheck.classList.contains('connectable') && connectionMode === ConnectionMode.Strict
? (isTarget && handle.type === 'source') || (!isTarget && handle.type === 'target')
: handleNodeId !== fromNodeId || handleId !== fromHandleId