Skip to content

Commit 5d5e3e8

Browse files
Add 'nopan' and 'nodrag' classes to Modal's overlay classes in order to always prevent react-flow to react to drag and pan actions in modals
1 parent cf8f29a commit 5d5e3e8

4 files changed

Lines changed: 9 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ This is a major release, and it might be not compatible with your current usage
2323
- First auto-completion item not marked as active when drop down first shown.
2424
- `<CodeEditor />`:
2525
- Enter key handling (adding new line) broken when `onKeyDown` is defined.
26+
- `<Modal />`:
27+
- Add 'nopan' and 'nodrag' classes to Modal's overlay classes in order to always prevent react-flow to react to drag and pan actions in modals.
2628

2729

2830
## [24.3.0] - 2025-06-05

src/cmem/react-flow/ReactFlow/ReactFlow.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,6 @@ export const ReactFlowExtended = React.forwardRef(ReactFlowExtendedPlain) as <T
233233
* @deprecated (v26) use `ReactFlowExtended`
234234
*/
235235
export const ReactFlow = ReactFlowExtended;
236+
237+
/** Classes that when set for an element, prevent that they trigger react-flow dragging and panning actions. */
238+
export const preventReactFlowActionsClasses = "nodrag nopan"

src/components/Dialog/Modal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { CLASSPREFIX as eccgui } from "../../configuration/constants";
1010
import { TestableComponent } from "../interfaces";
1111

1212
import { Card } from "./../Card";
13+
import {preventReactFlowActionsClasses} from "../../cmem";
1314

1415
export interface ModalProps extends TestableComponent, BlueprintOverlayProps {
1516
children: React.ReactNode | React.ReactNode[];
@@ -114,7 +115,7 @@ export const Modal = ({
114115
<BlueprintOverlay
115116
{...otherProps}
116117
backdropProps={backdropProps}
117-
className={overlayClassName}
118+
className={`${overlayClassName} ${preventReactFlowActionsClasses}`}
118119
backdropClassName={`${eccgui}-dialog__backdrop`}
119120
canOutsideClickClose={canOutsideClickClose}
120121
canEscapeKeyClose={canEscapeKeyClose}

src/components/Dialog/SimpleDialog.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ export const modalPreventEvents = {
136136
onDrag: (event: BaseSyntheticEvent) => event.stopPropagation(),
137137
onDragStart: (event: BaseSyntheticEvent) => event.stopPropagation(),
138138
onDragEnd: (event: BaseSyntheticEvent) => event.stopPropagation(),
139-
onMouseDown: (event: BaseSyntheticEvent) => event.stopPropagation(),
139+
// The following prevents some drop-downs to not close anymore when clicking outside of them
140+
// onMouseDown: (event: BaseSyntheticEvent) => event.stopPropagation(),
140141
onMouseUp: (event: BaseSyntheticEvent) => event.stopPropagation(),
141142
onClick: (event: BaseSyntheticEvent) => event.stopPropagation(),
142143
};

0 commit comments

Comments
 (0)