fix(handles): only check for matching handle id if an id exists
This commit is contained in:
@@ -27,7 +27,10 @@ const { onMouseDown, onClick } = useHandle({
|
|||||||
|
|
||||||
const isConnectable = computed(() => {
|
const isConnectable = computed(() => {
|
||||||
if (isString(connectable) && connectable === 'single') {
|
if (isString(connectable) && connectable === 'single') {
|
||||||
return !connectedEdges.value.some((edge) => edge[type.value] === nodeId && edge[`${type.value}Handle`] === handleId)
|
return !connectedEdges.value.some((edge) => {
|
||||||
|
const handle = edge[`${type.value}Handle`]
|
||||||
|
return edge[type.value] === nodeId && !!handle ? edge[`${type.value}Handle`] === handleId : true
|
||||||
|
})
|
||||||
} else if (isFunction(connectable)) {
|
} else if (isFunction(connectable)) {
|
||||||
return connectable(node, connectedEdges.value)
|
return connectable(node, connectedEdges.value)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,13 @@ export type ValidConnectionFunc = (
|
|||||||
elements: { edges: GraphEdge[]; sourceNode: GraphNode; targetNode: GraphNode },
|
elements: { edges: GraphEdge[]; sourceNode: GraphNode; targetNode: GraphNode },
|
||||||
) => boolean
|
) => boolean
|
||||||
|
|
||||||
/** set to true to allow unlimited connections, single for only one connection or use a cb function to determine connect-ability */
|
/**
|
||||||
|
* set to true to allow unlimited connections,
|
||||||
|
* single for only one connection
|
||||||
|
* or use a cb function to determine connect-ability
|
||||||
|
*
|
||||||
|
* if set to single and the handle already has more than one connection, it will act the same as setting it to false
|
||||||
|
*/
|
||||||
export type HandleConnectable = boolean | 'single' | ((node: GraphNode, connectedEdges: GraphEdge[]) => boolean)
|
export type HandleConnectable = boolean | 'single' | ((node: GraphNode, connectedEdges: GraphEdge[]) => boolean)
|
||||||
|
|
||||||
export interface HandleProps {
|
export interface HandleProps {
|
||||||
|
|||||||
Reference in New Issue
Block a user