@@ -195,19 +195,33 @@ function drawOne(gd, index) {
195195function forwardHoverClickAnywhere ( gd , path , plotinfo ) {
196196 if ( ! plotinfo ?. id ) return ;
197197
198- var node = path . node ( ) ;
198+ const node = path . node ( ) ;
199+
200+ // Fx.hover/Fx.click compute plot-area pixel coordinates from
201+ // evt.clientX/Y relative to evt.target's bounding box.
202+ // The shape path's bbox differs from the plot area, so we
203+ // re-target events to the subplot's nsewdrag element.
204+ function patchedEvt ( evt ) {
205+ const mainPlot = plotinfo . mainplotinfo || plotinfo ;
206+ const nsew = mainPlot ?. draglayer ?. select ( '.nsewdrag' ) . node ( ) ;
207+ if ( ! nsew ) return null ;
208+
209+ return { clientX : evt . clientX , clientY : evt . clientY , target : nsew } ;
210+ }
199211
200- node . addEventListener ( 'mousemove' , function ( evt ) {
212+ node . addEventListener ( 'mousemove' , ( evt ) => {
201213 if ( gd . _dragging ) return ;
202214 if ( gd . _fullLayout . hoveranywhere ) {
203- Fx . hover ( gd , evt , plotinfo . id ) ;
215+ const e = patchedEvt ( evt ) ;
216+ if ( e ) Fx . hover ( gd , e , plotinfo . id ) ;
204217 }
205218 } ) ;
206219
207- node . addEventListener ( 'click' , function ( evt ) {
220+ node . addEventListener ( 'click' , ( evt ) => {
208221 if ( gd . _dragged ) return ;
209222 if ( gd . _fullLayout . clickanywhere ) {
210- Fx . click ( gd , evt , plotinfo . id ) ;
223+ const e = patchedEvt ( evt ) ;
224+ if ( e ) Fx . click ( gd , e , plotinfo . id ) ;
211225 }
212226 } ) ;
213227}
0 commit comments