From 784a6729d195c97be74ab61ad9bf3ba14094b141 Mon Sep 17 00:00:00 2001 From: Andreas Schultz Date: Tue, 25 Aug 2026 12:47:49 +0200 Subject: [PATCH 1/3] Add nodrag class to Switch component by default --- CHANGELOG.md | 4 ++++ src/components/Switch/Switch.tsx | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7101c14eb..df34f9b95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - `utils` - `useComputedStyleFallback` option for `CssCustomProperties`: if the CSSOM does not provide any property name for the used selector, e.g. because the declarations are part of a constructed and adopted stylesheet, then the names are read from the computed style of the matching element; disabled by default because the computed style also contains all inherited custom properties +- `` + - `noDrag` parameter: Add the `nodrag` class to the Switch element. Default: true ### Changed @@ -23,6 +25,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - make the breakpoint configurable via SCSS (`$eccgui-propertyvalue-size-column-breakpoint-small`) - `utils` - values of CSS custom properties are resolved via the computed style of a matching element now, so they always represent what the browser really applies, e.g. references to other custom properties are already replaced +- `` + - Always add `nodrag` class to Switch. ### Fixed diff --git a/src/components/Switch/Switch.tsx b/src/components/Switch/Switch.tsx index 27e5cb026..b955c8554 100644 --- a/src/components/Switch/Switch.tsx +++ b/src/components/Switch/Switch.tsx @@ -17,18 +17,23 @@ export interface SwitchProps extends Omit { * class names */ className?: string; + + /** Adds the 'nodrag' class to the element, preventing dragging via the Switch element. Default: true */ + noDrag?: boolean } -export const Switch = ({ onChange, className, label, ...otherProps }: SwitchProps) => { +export const Switch = ({ onChange, className, label, noDrag = true, ...otherProps }: SwitchProps) => { const handleChange = (e: React.ChangeEvent) => { if (onChange) { onChange(!!e.target?.checked); } }; + const noDragClass = noDrag ? "nodrag " : "" + return ( Date: Wed, 26 Aug 2026 16:46:44 +0200 Subject: [PATCH 2/3] add story, improve docs --- CHANGELOG.md | 4 +--- src/components/Switch/Stories/Switch.stories.tsx | 11 +++++++++++ src/components/Switch/Switch.tsx | 4 ++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df34f9b95..87c0d3328 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - `utils` - `useComputedStyleFallback` option for `CssCustomProperties`: if the CSSOM does not provide any property name for the used selector, e.g. because the declarations are part of a constructed and adopted stylesheet, then the names are read from the computed style of the matching element; disabled by default because the computed style also contains all inherited custom properties - `` - - `noDrag` parameter: Add the `nodrag` class to the Switch element. Default: true + - `noDrag` parameter: Add the `nodrag` class to the Switch element. Default: `true` ### Changed @@ -25,8 +25,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - make the breakpoint configurable via SCSS (`$eccgui-propertyvalue-size-column-breakpoint-small`) - `utils` - values of CSS custom properties are resolved via the computed style of a matching element now, so they always represent what the browser really applies, e.g. references to other custom properties are already replaced -- `` - - Always add `nodrag` class to Switch. ### Fixed diff --git a/src/components/Switch/Stories/Switch.stories.tsx b/src/components/Switch/Stories/Switch.stories.tsx index f4967c89d..470caa2c3 100644 --- a/src/components/Switch/Stories/Switch.stories.tsx +++ b/src/components/Switch/Stories/Switch.stories.tsx @@ -23,3 +23,14 @@ WithStateLabel.args = { innerLabel: "Off", innerLabelChecked: "On", }; + +/** + * By default the `nodrag` class is set, so the switch cannot be used to drag a surrounding element, + * e.g. a React Flow node. Set `noDrag` to `false` to remove the class and allow the drag interaction. + */ +export const WithoutNoDragClass = Template.bind({}); +WithoutNoDragClass.args = { + ...Default.args, + label: "Switch label, drag interaction not prevented", + noDrag: false, +}; diff --git a/src/components/Switch/Switch.tsx b/src/components/Switch/Switch.tsx index b955c8554..d53dacee1 100644 --- a/src/components/Switch/Switch.tsx +++ b/src/components/Switch/Switch.tsx @@ -19,7 +19,7 @@ export interface SwitchProps extends Omit { className?: string; /** Adds the 'nodrag' class to the element, preventing dragging via the Switch element. Default: true */ - noDrag?: boolean + noDrag?: boolean; } export const Switch = ({ onChange, className, label, noDrag = true, ...otherProps }: SwitchProps) => { @@ -29,7 +29,7 @@ export const Switch = ({ onChange, className, label, noDrag = true, ...otherProp } }; - const noDragClass = noDrag ? "nodrag " : "" + const noDragClass = noDrag ? "nodrag " : ""; return ( Date: Thu, 27 Aug 2026 11:53:39 +0200 Subject: [PATCH 3/3] use variables for react flow opt-out class names --- CHANGELOG.md | 11 +++++++++-- src/cmem/react-flow/ReactFlow/ReactFlow.tsx | 3 --- src/cmem/react-flow/ReactFlow/constants.ts | 17 +++++++++++++++++ .../AutocompleteField/AutoCompleteField.tsx | 3 ++- src/components/Dialog/Modal.tsx | 2 +- src/components/Switch/Switch.tsx | 3 ++- src/extensions/react-flow/nodes/NodeContent.tsx | 7 ++++--- src/index.ts | 7 ++++++- 8 files changed, 41 insertions(+), 12 deletions(-) create mode 100644 src/cmem/react-flow/ReactFlow/constants.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 87c0d3328..a4e26fedb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,14 +6,21 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ## [Unreleased] +### Added + +- `` + - `noDrag` parameter: Add the `nodrag` class to the Switch element. Default: `true` + +### Deprecated + +- `preventReactFlowActionsClasses`: use `ClassNames.ReactFlow.preventAllActions` + ## [26.1.0] - 2026-08-20 ### Added - `utils` - `useComputedStyleFallback` option for `CssCustomProperties`: if the CSSOM does not provide any property name for the used selector, e.g. because the declarations are part of a constructed and adopted stylesheet, then the names are read from the computed style of the matching element; disabled by default because the computed style also contains all inherited custom properties -- `` - - `noDrag` parameter: Add the `nodrag` class to the Switch element. Default: `true` ### Changed diff --git a/src/cmem/react-flow/ReactFlow/ReactFlow.tsx b/src/cmem/react-flow/ReactFlow/ReactFlow.tsx index 5b1cb79be..2839a0828 100644 --- a/src/cmem/react-flow/ReactFlow/ReactFlow.tsx +++ b/src/cmem/react-flow/ReactFlow/ReactFlow.tsx @@ -207,6 +207,3 @@ const ReactFlowExtendedPlain = ( export const ReactFlowExtended = React.forwardRef(ReactFlowExtendedPlain) as ( p: T & { ref?: Ref }, ) => ReactElement; - -/** Classes that when set for an element, prevent that they trigger react-flow dragging, wheel and panning actions. */ -export const preventReactFlowActionsClasses = "nodrag nopan nowheel"; diff --git a/src/cmem/react-flow/ReactFlow/constants.ts b/src/cmem/react-flow/ReactFlow/constants.ts new file mode 100644 index 000000000..33f52b9a5 --- /dev/null +++ b/src/cmem/react-flow/ReactFlow/constants.ts @@ -0,0 +1,17 @@ +/* + Classes that when set for an element, prevent that they trigger react-flow dragging, wheel and panning actions. + + This module must stay free of imports, so that basic components can use these class names without pulling the + react-flow packages into their dependency chain. +*/ +export const preventReactFlowDragClass = "nodrag"; +export const preventReactFlowPanClass = "nopan"; +export const preventReactFlowWheelClass = "nowheel"; +export const preventReactFlowActionsClasses = `${preventReactFlowDragClass} ${preventReactFlowPanClass} ${preventReactFlowWheelClass}`; + +export const helperClasses = { + preventDrag: preventReactFlowDragClass, + preventPan: preventReactFlowPanClass, + preventWheel: preventReactFlowWheelClass, + preventAllActions: preventReactFlowActionsClasses, +}; diff --git a/src/components/AutocompleteField/AutoCompleteField.tsx b/src/components/AutocompleteField/AutoCompleteField.tsx index 2b8949461..770fc222e 100644 --- a/src/components/AutocompleteField/AutoCompleteField.tsx +++ b/src/components/AutocompleteField/AutoCompleteField.tsx @@ -5,6 +5,7 @@ import { } from "@blueprintjs/core"; import { Suggest as BlueprintSuggest } from "@blueprintjs/select"; +import { preventReactFlowDragClass } from "../../cmem/react-flow/ReactFlow/constants"; import { CLASSPREFIX as eccgui } from "../../configuration/constants"; import { ContextOverlayProps, @@ -485,7 +486,7 @@ export function SuggestField(props: SuggestFieldProps>({ )} {(menuButtons || (showExecutionButtons && executionButtons)) && ( -
+
{showExecutionButtons && typeof executionButtons === "function" ? executionButtons(adjustedContentProps, setAdjustedContentProps) : null} @@ -782,7 +783,7 @@ export function NodeContent>({ (resizeDirections!.right ? ` ${eccgui}-graphviz__node__resizer--right` : "") + (resizeDirections!.bottom ? ` ${eccgui}-graphviz__node__resizer--bottom` : "") } - handleWrapperClass={`${eccgui}-graphviz__node__resizer--cursorhandles` + " nodrag"} + handleWrapperClass={`${eccgui}-graphviz__node__resizer--cursorhandles ${preventReactFlowDragClass}`} size={resizableSize} maxHeight={resizeMaxDimensions?.height ?? undefined} maxWidth={resizeMaxDimensions?.width ?? undefined} diff --git a/src/index.ts b/src/index.ts index b6b9e8c56..c89288a26 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,6 @@ import { Classes as BlueprintClasses } from "@blueprintjs/core"; +import {helperClasses as reactFlowHelperClasses } from "./cmem/react-flow/ReactFlow/constants"; import { ClassNames as IntentClassNames } from "./common/Intent"; import * as Skeleton from "./components/Skeleton/classnames"; import * as TypographyClassNames from "./components/Typography/classnames"; @@ -9,12 +10,16 @@ const ClassNames = { Intent: IntentClassNames, Skeleton, Typography: TypographyClassNames, + ReactFlow: reactFlowHelperClasses, }; +/** @deprecated (v27) use `ClassNames.ReactFlow.preventAllActions` */ +const preventReactFlowActionsClasses = reactFlowHelperClasses.preventAllActions; + export * from "./configuration/constants"; export * from "./common"; export * from "./components"; export * from "./extensions"; export * from "./cmem"; -export { ClassNames }; +export { ClassNames, preventReactFlowActionsClasses };