From 2ddc5505a3202f5a54c00c865787479154a4a135 Mon Sep 17 00:00:00 2001 From: moklick Date: Sun, 21 Mar 2021 17:15:23 +0100 Subject: [PATCH] fix(handle): check if source or target exist --- src/components/Handle/handler.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/Handle/handler.ts b/src/components/Handle/handler.ts index 5b589b29..515758e7 100644 --- a/src/components/Handle/handler.ts +++ b/src/components/Handle/handler.ts @@ -99,9 +99,10 @@ export function onMouseDown( ): void { const reactFlowNode = (event.target as Element).closest('.react-flow'); const elementBelow = document.elementFromPoint(event.clientX, event.clientY); - const elementBelowIsTarget = elementBelow?.classList.contains('target') || false; + const elementBelowIsTarget = elementBelow?.classList.contains('target'); + const elementBelowIsSource = elementBelow?.classList.contains('source'); - if (!reactFlowNode) { + if (!reactFlowNode || (!elementBelowIsTarget && !elementBelowIsSource)) { return; }