From 464db502612e9954df1775b24b712066afad9109 Mon Sep 17 00:00:00 2001 From: Alex Hsu Date: Fri, 1 May 2026 08:28:15 -0400 Subject: [PATCH] Fix hoveranywhere/clickanywhere events over editable shapes --- src/components/shapes/draw.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/components/shapes/draw.js b/src/components/shapes/draw.js index 1a9307cfb67..cf9f95d871d 100644 --- a/src/components/shapes/draw.js +++ b/src/components/shapes/draw.js @@ -17,6 +17,7 @@ var Drawing = require('../drawing'); var arrayEditor = require('../../plot_api/plot_template').arrayEditor; var dragElement = require('../dragelement'); +var Fx = require('../fx'); var setCursor = require('../../lib/setcursor'); var constants = require('./constants'); @@ -188,9 +189,35 @@ function drawOne(gd, index) { } } path.node().addEventListener('click', function() { return activateShape(gd, path); }); + + // Editable / shape-position-edit shapes get inline pointer-events + // that prevent mouse events from reaching the maindrag, where + // hoveranywhere / clickanywhere are wired up. Forward those events + // from the shape so the layout-level events still fire. + forwardHoverClickAnywhere(gd, path, plotinfo); } } +function forwardHoverClickAnywhere(gd, path, plotinfo) { + if(!plotinfo || !plotinfo.id) return; + + var node = path.node(); + + node.addEventListener('mousemove', function(evt) { + if(gd._dragging) return; + if(gd._fullLayout.hoveranywhere) { + Fx.hover(gd, evt, plotinfo.id); + } + }); + + node.addEventListener('click', function(evt) { + if(gd._dragged) return; + if(gd._fullLayout.clickanywhere) { + Fx.click(gd, evt, plotinfo.id); + } + }); +} + function setClipPath(shapePath, gd, shapeOptions) { // note that for layer="below" the clipAxes can be different from the // subplot we're drawing this in. This could cause problems if the shape