@@ -2607,6 +2607,56 @@ describe('hover updates', function() {
26072607 } )
26082608 . then ( done ) ;
26092609 } ) ;
2610+
2611+ it ( 'should not attempt to rehover over exiting subplots' , function ( done ) {
2612+ spyOn ( Fx , 'hover' ) . and . callThrough ( ) ;
2613+
2614+ var data = [
2615+ { y : [ 1 ] , hoverinfo : 'y' } ,
2616+ { y : [ 2 ] , hoverinfo : 'y' , xaxis : 'x2' , yaxis : 'y2' }
2617+ ] ;
2618+
2619+ var data2 = [
2620+ { y : [ 1 ] , hoverinfo : 'y' }
2621+ ] ;
2622+
2623+ var layout = {
2624+ xaxis : { domain : [ 0 , 0.5 ] } ,
2625+ xaxis2 : { anchor : 'y2' , domain : [ 0.5 , 1 ] } ,
2626+ yaxis2 : { anchor : 'x2' } ,
2627+ width : 400 ,
2628+ height : 200 ,
2629+ margin : { l : 0 , t : 0 , r : 0 , b : 0 } ,
2630+ showlegend : false
2631+ } ;
2632+
2633+ var gd = createGraphDiv ( ) ;
2634+ var onPt2 = [ 300 , 100 ] ;
2635+ var offPt2 = [ 250 , 100 ] ;
2636+
2637+ Plotly . react ( gd , data , layout )
2638+ . then ( function ( ) {
2639+ assertLabelsCorrect ( onPt2 , [ 303 , 100 ] , '2' , 'after 1st draw [on-pt]' ) ;
2640+ assertLabelsCorrect ( offPt2 , null , null , 'after 1st draw [off-pt]' ) ;
2641+ expect ( Fx . hover ) . toHaveBeenCalledTimes ( 2 ) ;
2642+ } )
2643+ . then ( function ( ) {
2644+ var promise = Plotly . react ( gd , data2 , layout ) ;
2645+ assertLabelsCorrect ( onPt2 , null , null , '2' , 'before react() resolves [on-pt]' ) ;
2646+ assertLabelsCorrect ( offPt2 , null , null , 'before react() resolves [off-pt]' ) ;
2647+ // N.B. no calls from Plots.rehover() as x2y2 subplot got removed!
2648+ expect ( Fx . hover ) . toHaveBeenCalledTimes ( 2 ) ;
2649+ return promise ;
2650+ } )
2651+ . then ( function ( ) {
2652+ expect ( Fx . hover ) . toHaveBeenCalledTimes ( 2 ) ;
2653+ assertLabelsCorrect ( onPt2 , null , null , '2' , 'after react() resolves [on-pt]' ) ;
2654+ assertLabelsCorrect ( offPt2 , null , null , 'after react() resolves [off-pt]' ) ;
2655+ expect ( Fx . hover ) . toHaveBeenCalledTimes ( 2 ) ;
2656+ } )
2657+ . catch ( failTest )
2658+ . then ( done ) ;
2659+ } ) ;
26102660} ) ;
26112661
26122662describe ( 'Test hover label custom styling:' , function ( ) {
0 commit comments