From 00282c2cb49353f80f41b1bc646ec2a37cbbd2cd Mon Sep 17 00:00:00 2001 From: Jack Fishwick Date: Mon, 26 Sep 2022 18:09:37 +0100 Subject: [PATCH] feat: only trigger a pane 'click' if there is no movement. --- packages/core/src/components/UserSelection/index.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/core/src/components/UserSelection/index.tsx b/packages/core/src/components/UserSelection/index.tsx index e6435cd4..fbcc9974 100644 --- a/packages/core/src/components/UserSelection/index.tsx +++ b/packages/core/src/components/UserSelection/index.tsx @@ -117,7 +117,13 @@ const UserSelection = memo(({ isSelectionMode, onClick, onContextMenu, onWheel, setUserSelectionRect(nextUserSelectRect); }; - const onMouseUp = () => { + const onMouseUp = (event: React.MouseEvent) => { + // We only want to trigger click functions when in selection mode if + // the user did not move the mouse. + if (!userSelectionActive && userSelectionRect) { + onClick?.(event); + } + store.setState({ nodesSelectionActive: prevSelectedNodesCount.current > 0 }); resetUserSelection(); @@ -131,7 +137,6 @@ const UserSelection = memo(({ isSelectionMode, onClick, onContextMenu, onWheel, const eventHandlers = elementsSelectable && (isSelectionMode || userSelectionActive) ? { - onClick, onContextMenu, onWheel, onMouseDown,