Skip to content

Commit

Permalink
fix(core): add flow id to handle ids
Browse files Browse the repository at this point in the history
Signed-off-by: braks <[email protected]>
  • Loading branch information
bcakmakoglu committed Nov 29, 2024
1 parent 00a4e78 commit 63175de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/core/src/components/Handle/Handle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const type = toRef(() => props.type ?? 'source')
const isValidConnection = toRef(() => props.isValidConnection ?? null)
const {
id: flowId,
connectionStartHandle,
connectionClickStartHandle,
connectionEndHandle,
Expand Down Expand Up @@ -179,7 +180,7 @@ export default {
<template>
<div
ref="handle"
:data-id="`${nodeId}-${handleId}-${type}`"
:data-id="`${flowId}-${nodeId}-${handleId}-${type}`"
:data-handleid="handleId"
:data-nodeid="nodeId"
:data-handlepos="position"
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/utils/handle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export function getClosestHandle(
}

// determine absolute position of the handle
const { x, y } = getHandlePosition(node, handle, handle.position, true)
const { x, y } = getHandlePosition(node, handle, handle.position)

const distance = Math.sqrt((x - position.x) ** 2 + (y - position.y) ** 2)
if (distance > connectionRadius) {
Expand All @@ -112,6 +112,7 @@ export function getClosestHandle(
if (!closestHandles.length) {
return null
}

// when multiple handles overlay each other we prefer the opposite handle
if (closestHandles.length > 1) {
const oppositeHandleType = fromHandle.type === 'source' ? 'target' : 'source'
Expand Down

0 comments on commit 63175de

Please sign in to comment.