diff --git a/packages/core/src/container/FlowRenderer/index.tsx b/packages/core/src/container/FlowRenderer/index.tsx
index e3faed9c..fda81982 100644
--- a/packages/core/src/container/FlowRenderer/index.tsx
+++ b/packages/core/src/container/FlowRenderer/index.tsx
@@ -44,6 +44,7 @@ const FlowRenderer = ({
onMoveStart,
onMoveEnd,
selectionKeyCode,
+ selectBoxOnDrag,
multiSelectionKeyCode,
zoomActivationKeyCode,
elementsSelectable,
@@ -84,7 +85,6 @@ const FlowRenderer = ({
onMove={onMove}
onMoveStart={onMoveStart}
onMoveEnd={onMoveEnd}
- selectionKeyPressed={selectionKeyPressed}
elementsSelectable={elementsSelectable}
zoomOnScroll={zoomOnScroll}
zoomOnPinch={zoomOnPinch}
@@ -103,7 +103,7 @@ const FlowRenderer = ({
noPanClassName={noPanClassName}
>
{children}
-
+
{nodesSelectionActive && (
(
connectionLineContainerStyle,
deleteKeyCode = 'Backspace',
selectionKeyCode = 'Shift',
+ selectBoxOnDrag = false,
multiSelectionKeyCode = 'Meta',
zoomActivationKeyCode = 'Meta',
snapToGrid = false,
@@ -193,6 +194,7 @@ const ReactFlow = forwardRef(
connectionLineComponent={connectionLineComponent}
connectionLineContainerStyle={connectionLineContainerStyle}
selectionKeyCode={selectionKeyCode}
+ selectBoxOnDrag={selectBoxOnDrag}
deleteKeyCode={deleteKeyCode}
multiSelectionKeyCode={multiSelectionKeyCode}
zoomActivationKeyCode={zoomActivationKeyCode}
diff --git a/packages/core/src/container/ZoomPane/index.tsx b/packages/core/src/container/ZoomPane/index.tsx
index a5783a7a..fce3a35f 100644
--- a/packages/core/src/container/ZoomPane/index.tsx
+++ b/packages/core/src/container/ZoomPane/index.tsx
@@ -16,8 +16,13 @@ import type { Viewport, ReactFlowState } from '../../types';
type ZoomPaneProps = Omit<
FlowRendererProps,
- 'deleteKeyCode' | 'selectionKeyCode' | 'multiSelectionKeyCode' | 'noDragClassName' | 'disableKeyboardA11y'
-> & { selectionKeyPressed: boolean };
+ | 'deleteKeyCode'
+ | 'selectionKeyCode'
+ | 'multiSelectionKeyCode'
+ | 'noDragClassName'
+ | 'disableKeyboardA11y'
+ | 'selectBoxOnDrag'
+>;
const viewChanged = (prevViewport: Viewport, eventViewport: any): boolean =>
prevViewport.x !== eventViewport.x || prevViewport.y !== eventViewport.y || prevViewport.zoom !== eventViewport.k;
@@ -46,7 +51,6 @@ const ZoomPane = ({
panOnScrollSpeed = 0.5,
panOnScrollMode = PanOnScrollMode.Free,
zoomOnDoubleClick = true,
- selectionKeyPressed,
elementsSelectable,
panOnDrag = true,
defaultViewport,
@@ -151,9 +155,9 @@ const ZoomPane = ({
useEffect(() => {
if (d3Zoom) {
- if (selectionKeyPressed && !isZoomingOrPanning.current) {
+ if (store.getState().userSelectionActive && !isZoomingOrPanning.current) {
d3Zoom.on('zoom', null);
- } else if (!selectionKeyPressed) {
+ } else if (!store.getState().userSelectionActive) {
d3Zoom.on('zoom', (event: D3ZoomEvent) => {
const { onViewportChange } = store.getState();
@@ -168,7 +172,7 @@ const ZoomPane = ({
});
}
}
- }, [selectionKeyPressed, d3Zoom, onMove]);
+ }, [store, d3Zoom, onMove]);
useEffect(() => {
if (d3Zoom) {
@@ -238,7 +242,7 @@ const ZoomPane = ({
}
// during a selection we prevent all other interactions
- if (selectionKeyPressed) {
+ if (store.getState().userSelectionActive) {
return false;
}
@@ -276,13 +280,13 @@ const ZoomPane = ({
});
}
}, [
+ store,
d3Zoom,
zoomOnScroll,
zoomOnPinch,
panOnScroll,
zoomOnDoubleClick,
panOnDrag,
- selectionKeyPressed,
elementsSelectable,
zoomActivationKeyPressed,
]);
diff --git a/packages/core/src/types/component-props.ts b/packages/core/src/types/component-props.ts
index 9b273641..456122ce 100644
--- a/packages/core/src/types/component-props.ts
+++ b/packages/core/src/types/component-props.ts
@@ -94,6 +94,7 @@ export type ReactFlowProps = HTMLAttributes & {
connectionMode?: ConnectionMode;
deleteKeyCode?: KeyCode | null;
selectionKeyCode?: KeyCode | null;
+ selectBoxOnDrag?: boolean;
multiSelectionKeyCode?: KeyCode | null;
zoomActivationKeyCode?: KeyCode | null;
snapToGrid?: boolean;