diff --git a/public/app/features/canvas/runtime/SceneTransformWrapper.tsx b/public/app/features/canvas/runtime/SceneTransformWrapper.tsx index eaa8cdad860..005f23bc4ac 100644 --- a/public/app/features/canvas/runtime/SceneTransformWrapper.tsx +++ b/public/app/features/canvas/runtime/SceneTransformWrapper.tsx @@ -19,6 +19,20 @@ export const SceneTransformWrapper = ({ scene, children: sceneDiv }: SceneTransf scene.scale = scale; }; + const onSceneContainerMouseDown = (e: React.MouseEvent) => { + // If pan and zoom is disabled or context menu is visible, don't pan + if ((!scene.shouldPanZoom || scene.contextMenuVisible) && (e.button === 1 || (e.button === 2 && e.ctrlKey))) { + e.preventDefault(); + e.stopPropagation(); + } + + // If context menu is hidden, ignore left mouse or non-ctrl right mouse for pan + if (!scene.contextMenuVisible && !scene.isPanelEditing && e.button === 2 && !e.ctrlKey) { + e.preventDefault(); + e.stopPropagation(); + } + }; + return ( - {sceneDiv} + + {/* The
element has child elements that allow for mouse events, so we need to disable the linter rule */} + {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */} +
{sceneDiv}
+ ); }; diff --git a/public/app/features/canvas/runtime/scene.tsx b/public/app/features/canvas/runtime/scene.tsx index 7816c09e62f..4031523ece0 100644 --- a/public/app/features/canvas/runtime/scene.tsx +++ b/public/app/features/canvas/runtime/scene.tsx @@ -668,30 +668,8 @@ export class Scene { const isTooltipValid = (this.tooltip?.element?.data?.links?.length ?? 0) > 0; const canShowElementTooltip = !this.isEditingEnabled && isTooltipValid; - const onSceneContainerMouseDown = (e: React.MouseEvent) => { - // If pan and zoom is disabled or context menu is visible, don't pan - if ((!this.shouldPanZoom || this.contextMenuVisible) && (e.button === 1 || (e.button === 2 && e.ctrlKey))) { - e.preventDefault(); - e.stopPropagation(); - } - - // If context menu is hidden, ignore left mouse or non-ctrl right mouse for pan - if (!this.contextMenuVisible && !this.isPanelEditing && e.button === 2 && !e.ctrlKey) { - e.preventDefault(); - e.stopPropagation(); - } - }; - const sceneDiv = ( - // The
element has child elements that allow for mouse events, so we need to disable the linter rule - // eslint-disable-next-line jsx-a11y/no-static-element-interactions -
+
{this.connections.render()} {this.root.render()} {this.isEditingEnabled && (