@@ -886,4 +886,62 @@ describe('hover updates', function() {
886
886
return assertLabelsCorrect ( null , [ 103 , 100 ] , 'trace 10.5' ) ;
887
887
} ) . catch ( fail ) . then ( done ) ;
888
888
} ) ;
889
+
890
+ it ( 'should not trigger infinite loop of plotly_unhover events' , function ( done ) {
891
+ var gd = createGraphDiv ( ) ;
892
+ var colors0 = [ '#00000' , '#00000' , '#00000' , '#00000' , '#00000' , '#00000' , '#00000' ] ;
893
+
894
+ function unhover ( ) {
895
+ return new Promise ( function ( resolve ) {
896
+ mouseEvent ( 'mousemove' , 394 , 285 ) ;
897
+ setTimeout ( function ( ) {
898
+ resolve ( ) ;
899
+ } , constants . HOVERMINTIME ) ;
900
+ } ) ;
901
+ }
902
+
903
+ var hoverCnt = 0 ;
904
+ var unHoverCnt = 0 ;
905
+
906
+ Plotly . plot ( gd , [ {
907
+ mode : 'markers' ,
908
+ x : [ 1 , 2 , 3 , 4 , 5 , 6 , 7 ] ,
909
+ y : [ 1 , 2 , 3 , 2 , 3 , 4 , 3 ] ,
910
+ marker : {
911
+ size : 16 ,
912
+ colors : colors0 . slice ( )
913
+ }
914
+ } ] )
915
+ . then ( function ( ) {
916
+
917
+ gd . on ( 'plotly_hover' , function ( eventData ) {
918
+ hoverCnt ++ ;
919
+
920
+ var pt = eventData . points [ 0 ] ;
921
+ Plotly . restyle ( gd , 'marker.color[' + pt . pointNumber + ']' , 'red' ) ;
922
+ } ) ;
923
+
924
+ gd . on ( 'plotly_unhover' , function ( ) {
925
+ unHoverCnt ++ ;
926
+
927
+ Plotly . restyle ( gd , 'marker.color' , [ colors0 . slice ( ) ] ) ;
928
+ } ) ;
929
+
930
+ return assertLabelsCorrect ( [ 351 , 251 ] , [ 358 , 272 ] , '2' ) ;
931
+ } )
932
+ . then ( unhover )
933
+ . then ( function ( ) {
934
+ expect ( hoverCnt ) . toEqual ( 1 ) ;
935
+ expect ( unHoverCnt ) . toEqual ( 1 ) ;
936
+
937
+ return assertLabelsCorrect ( [ 400 , 200 ] , [ 435 , 198 ] , '3' ) ;
938
+ } )
939
+ . then ( unhover )
940
+ . then ( function ( ) {
941
+ expect ( hoverCnt ) . toEqual ( 2 ) ;
942
+ expect ( unHoverCnt ) . toEqual ( 2 ) ;
943
+ } )
944
+ . then ( done ) ;
945
+
946
+ } ) ;
889
947
} ) ;
0 commit comments