Skip to content

Commit

Permalink
feat: Click on svg background to terminate edge creation [PT-185596253]
Browse files Browse the repository at this point in the history
  • Loading branch information
dougmartin committed Jul 13, 2023
1 parent 9c709ad commit ade7ca1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/drawing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,14 @@ export const Drawing = (props: Props) => {
if (drawingMode === "addNode") {
addNode(translateToGraphPoint(e));
handleSetSelectMode();
} else if (drawingMode === "addEdge") {
const onSVGBackground = ((e.target as HTMLElement)?.tagName || "").toLowerCase() === "svg";
if (onSVGBackground) {
clearSelections();
handleSetSelectMode();
}
}
}, [drawingMode, addNode, handleSetSelectMode]);
}, [drawingMode, addNode, handleSetSelectMode, clearSelections]);

// allow nodes to be "dragged" from the toolbar to the canvas
const handleMouseUp = useCallback((e: React.MouseEvent<HTMLDivElement>) => {
Expand Down

0 comments on commit ade7ca1

Please sign in to comment.