diff --git a/packages/core/src/components/UserSelection/index.tsx b/packages/core/src/components/UserSelection/index.tsx index 21d07a2c..25ed3296 100644 --- a/packages/core/src/components/UserSelection/index.tsx +++ b/packages/core/src/components/UserSelection/index.tsx @@ -15,7 +15,7 @@ import { SelectionMode } from '../../types'; import type { XYPosition, ReactFlowState, NodeChange, EdgeChange } from '../../types'; type UserSelectionProps = { - isSelectionMode: boolean; + isSelecting: boolean; selectionMode?: SelectionMode; panOnDrag?: boolean | 'RightClick'; onSelectionStart?: (e: ReactMouseEvent) => void; @@ -56,7 +56,7 @@ const selector = (s: ReactFlowState) => ({ const UserSelection = memo( ({ - isSelectionMode, + isSelecting, selectionMode = SelectionMode.Contained, panOnDrag, onSelectionStart, @@ -102,13 +102,7 @@ const UserSelection = memo( const onMouseDown = (event: ReactMouseEvent): void => { const { resetSelectedElements, domNode } = store.getState(); - if ( - !elementsSelectable || - !isSelectionMode || - event.button !== 0 || - event.target !== container.current || - !domNode - ) { + if (!elementsSelectable || !isSelecting || event.button !== 0 || event.target !== container.current || !domNode) { return; } @@ -134,7 +128,7 @@ const UserSelection = memo( const onMouseMove = (event: ReactMouseEvent): void => { const { userSelectionRect, nodeInternals, edges, transform, onNodesChange, onEdgesChange, nodeOrigin, getNodes } = store.getState(); - if (!isSelectionMode || !containerBounds.current || !userSelectionRect) { + if (!isSelecting || !containerBounds.current || !userSelectionRect) { return; } @@ -208,14 +202,14 @@ const UserSelection = memo( resetUserSelection(); }; - const hasActiveSelection = elementsSelectable && (isSelectionMode || userSelectionActive); + const hasActiveSelection = elementsSelectable && (isSelecting || userSelectionActive); return (
{ const nodesSelectionActive = useStore(selector); const selectionKeyPressed = useKeyPress(selectionKeyCode); - - const isSelectionMode = selectionKeyPressed || (selectionOnDrag && panOnDrag !== true); + const isSelecting = selectionKeyPressed || (selectionOnDrag && panOnDrag !== true); useGlobalKeyHandler({ deleteKeyCode, multiSelectionKeyCode }); @@ -107,7 +106,7 @@ const FlowRenderer = ({ onPaneContextMenu={onPaneContextMenu} onPaneScroll={onPaneScroll} panOnDrag={panOnDrag} - isSelectionMode={!!isSelectionMode} + isSelecting={!!isSelecting} selectionMode={selectionMode} > {children}