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

This commit is contained in:
Braks
2022-05-14 18:26:55 +02:00
parent 1d2322eb46
commit d36402e537
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -70,7 +70,7 @@ const handleEdgeUpdater = (event: MouseEvent, isSourceHandle: boolean) => {
undefined, undefined,
isSourceHandle ? 'target' : 'source', isSourceHandle ? 'target' : 'source',
(connection) => { (connection) => {
if (!connectionExists(edge, getEdges)) emits.edgeUpdate({ edge, connection }) if (!connectionExists(connection, getEdges)) emits.edgeUpdate({ edge, connection })
}, },
() => emits.edgeUpdateEnd({ event, edge }), () => emits.edgeUpdateEnd({ event, edge }),
) )
@@ -172,7 +172,7 @@ export default {
<g <g
:class="getClass()" :class="getClass()"
@click="onEdgeClick" @click="onEdgeClick"
@dblClick="onDoubleClick" @dbl-click="onDoubleClick"
@contextmenu="onEdgeContextMenu" @contextmenu="onEdgeContextMenu"
@mouseenter="onEdgeMouseEnter" @mouseenter="onEdgeMouseEnter"
@mousemove="onEdgeMouseMove" @mousemove="onEdgeMouseMove"
+1 -1
View File
@@ -129,7 +129,7 @@ export const getIncomers = (node: GraphNode, elements: Elements) => getConnected
export const getEdgeId = ({ source, sourceHandle, target, targetHandle }: Connection) => export const getEdgeId = ({ source, sourceHandle, target, targetHandle }: Connection) =>
`vueflow__edge-${source}${sourceHandle ?? ''}-${target}${targetHandle ?? ''}` `vueflow__edge-${source}${sourceHandle ?? ''}-${target}${targetHandle ?? ''}`
export const connectionExists = (edge: Edge, elements: Elements) => export const connectionExists = (edge: Edge | Connection, elements: Elements) =>
elements.some( elements.some(
(el) => (el) =>
isEdge(el) && isEdge(el) &&