From 0dbe2a2059a8c74833e9bd67c0d641a5d04ad890 Mon Sep 17 00:00:00 2001 From: Doug Martin Date: Tue, 11 Jul 2023 07:33:11 -0400 Subject: [PATCH] feat: Change to press and drag to create nodes [PT-185572242] This adds the ability to "drag" nodes from the tool palette along with keeping the click to create behavior --- src/components/drawing.tsx | 12 +++++++++++- src/components/graph.tsx | 11 +++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/components/drawing.tsx b/src/components/drawing.tsx index e1cd3a9..66ccfc6 100644 --- a/src/components/drawing.tsx +++ b/src/components/drawing.tsx @@ -180,6 +180,15 @@ export const Drawing = (props: Props) => { } }, [drawingMode, addNode, handleSetSelectMode]); + // allow nodes to be "dragged" from the toolbar to the canvas + const handleMouseUp = useCallback((e: React.MouseEvent) => { + if (drawingMode === "addNode") { + handleClicked(e); + e.preventDefault(); + e.stopPropagation(); + } + }, [drawingMode, handleClicked]); + const handleNodeClicked = useCallback((id: string, onLoop?: boolean) => { const node = getNode(id); if (!node) { @@ -296,7 +305,7 @@ export const Drawing = (props: Props) => {