fix(edges): Check if connection exists for new connection

This commit is contained in:
Braks
2022-05-13 10:07:27 +02:00
parent 1d2322eb46
commit d36402e537
2 changed files with 3 additions and 3 deletions

View File

@@ -70,7 +70,7 @@ const handleEdgeUpdater = (event: MouseEvent, isSourceHandle: boolean) => {
undefined,
isSourceHandle ? 'target' : 'source',
(connection) => {
if (!connectionExists(edge, getEdges)) emits.edgeUpdate({ edge, connection })
if (!connectionExists(connection, getEdges)) emits.edgeUpdate({ edge, connection })
},
() => emits.edgeUpdateEnd({ event, edge }),
)
@@ -172,7 +172,7 @@ export default {
<g
:class="getClass()"
@click="onEdgeClick"
@dblClick="onDoubleClick"
@dbl-click="onDoubleClick"
@contextmenu="onEdgeContextMenu"
@mouseenter="onEdgeMouseEnter"
@mousemove="onEdgeMouseMove"

View File

@@ -129,7 +129,7 @@ export const getIncomers = (node: GraphNode, elements: Elements) => getConnected
export const getEdgeId = ({ source, sourceHandle, target, targetHandle }: Connection) =>
`vueflow__edge-${source}${sourceHandle ?? ''}-${target}${targetHandle ?? ''}`
export const connectionExists = (edge: Edge, elements: Elements) =>
export const connectionExists = (edge: Edge | Connection, elements: Elements) =>
elements.some(
(el) =>
isEdge(el) &&