Skip to content

Commit 0359afb

Browse files
authored
Merge pull request #348 from eccenca/fix/reactFlowModal-MT-30
Make react-flow prevent-event classes configurable in Modal
2 parents a5949e8 + 2dee28e commit 0359afb

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ This is a major release, and it might be not compatible with your current usage
5959
- `toggler-caretleft`
6060
- `toggler-micon`
6161
- `toggler-micoff`
62+
- `<Modal />`:
63+
- `preventReactFlowEvents`: Adds 'nopan', 'nowheel' and 'nodrag' classes to Modal's overlay classes in order to prevent react-flow to react to drag and pan actions in modals.
64+
This is enabled by default for <SimpleDialog />.
65+
6266

6367
### Removed
6468

@@ -86,8 +90,6 @@ This is a major release, and it might be not compatible with your current usage
8690

8791
### Fixed
8892

89-
- `<Modal />`:
90-
- Add 'nopan', 'nowheel' and 'nodrag' classes to Modal's overlay classes in order to always prevent react-flow to react to drag and pan actions in modals.
9193
- `<CodeAutocompleteField />`:
9294
- In multiline mode, validation errors might be highlighted incorrectly (relative line offset added).
9395

src/components/Dialog/Modal.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import {
55
Overlay2Props as BlueprintOverlayProps,
66
} from "@blueprintjs/core";
77

8+
import { preventReactFlowActionsClasses } from "../../cmem";
89
import { utils } from "../../common";
910
import { CLASSPREFIX as eccgui } from "../../configuration/constants";
1011
import { TestableComponent } from "../interfaces";
1112

1213
import { Card } from "./../Card";
13-
import {preventReactFlowActionsClasses} from "../../cmem";
1414

1515
export interface ModalProps extends TestableComponent, BlueprintOverlayProps {
1616
children: React.ReactNode | React.ReactNode[];
@@ -43,9 +43,11 @@ export interface ModalProps extends TestableComponent, BlueprintOverlayProps {
4343
* If this option is used inflationary then this could harm the visibility of other overlays.
4444
*/
4545
forceTopPosition?: boolean;
46+
/** Prevents that pan and zooming actions of an existing react-flow instance are triggered while this Modal is open. */
47+
preventReactFlowEvents?: boolean;
4648
}
4749

48-
export type ModalSize = "tiny" | "small" | "regular" | "large" | "xlarge" | "fullscreen"
50+
export type ModalSize = "tiny" | "small" | "regular" | "large" | "xlarge" | "fullscreen";
4951

5052
/**
5153
* Displays contents on top of other elements, used to create dialogs.
@@ -68,6 +70,7 @@ export const Modal = ({
6870
onOpening,
6971
"data-test-id": dataTestId,
7072
"data-testid": dataTestid,
73+
preventReactFlowEvents = true,
7174
...otherProps
7275
}: ModalProps) => {
7376
const backdropProps: React.HTMLProps<HTMLDivElement> | undefined =
@@ -117,7 +120,7 @@ export const Modal = ({
117120
<BlueprintOverlay
118121
{...otherProps}
119122
backdropProps={backdropProps}
120-
className={`${overlayClassName} ${preventReactFlowActionsClasses}`}
123+
className={`${overlayClassName} ${preventReactFlowEvents ? preventReactFlowActionsClasses : ""}`}
121124
backdropClassName={`${eccgui}-dialog__backdrop`}
122125
canOutsideClickClose={canOutsideClickClose}
123126
canEscapeKeyClose={canEscapeKeyClose}

0 commit comments

Comments
 (0)