Skip to content

Commit b3b2acc

Browse files
committed
do not flag conflict if the edge to check is already in reactflow
Signed-off-by: Teo Koon Peng <[email protected]>
1 parent f59b48c commit b3b2acc

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

diagram-editor/frontend/utils/connection.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,19 @@ export function checkValidEdgeSimple(
166166
const outputCardinality = getOutputCardinality(sourceNode.type);
167167
switch (outputCardinality) {
168168
case CardinalityType.Single: {
169-
if (reactFlow.getEdges().some((edge) => edge.source === sourceNode.id)) {
169+
if (
170+
reactFlow
171+
.getEdges()
172+
.some((e) => e.source === sourceNode.id && edge.id !== e.id)
173+
) {
170174
return createValidationError('source node already has an edge');
171175
}
172176
break;
173177
}
174178
case CardinalityType.Pair: {
175179
let count = 0;
176-
for (const edge of reactFlow.getEdges()) {
177-
if (edge.source === sourceNode.id) {
180+
for (const e of reactFlow.getEdges()) {
181+
if (e.source === sourceNode.id && edge.id !== e.id) {
178182
count++;
179183
}
180184
if (count > 1) {

0 commit comments

Comments
 (0)