@@ -451,7 +451,9 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
451451 dragOptions . doneFnCompleted ( selection ) ;
452452 }
453453
454- emitSelected ( gd , eventData ) ;
454+ if ( isSelectMode ) {
455+ emitSelected ( gd , eventData ) ;
456+ }
455457 } ) . catch ( Lib . error ) ;
456458 } ;
457459}
@@ -673,15 +675,23 @@ function coerceSelectionsCache(evt, gd, dragOptions) {
673675 }
674676}
675677
678+ function hasActiveShape ( gd ) {
679+ return gd . _fullLayout . _activeShapeIndex >= 0 ;
680+ }
681+
682+ function hasActiveSelection ( gd ) {
683+ return gd . _fullLayout . _activeSelectionIndex >= 0 ;
684+ }
685+
676686function clearSelectionsCache ( dragOptions , immediateSelect ) {
677687 var dragmode = dragOptions . dragmode ;
678688 var plotinfo = dragOptions . plotinfo ;
679689
680690 var gd = dragOptions . gd ;
681- if ( gd . _fullLayout . _activeShapeIndex >= 0 ) {
691+ if ( hasActiveShape ( gd ) ) {
682692 gd . _fullLayout . _deactivateShape ( gd ) ;
683693 }
684- if ( gd . _fullLayout . _activeSelectionIndex >= 0 ) {
694+ if ( hasActiveSelection ( gd ) ) {
685695 gd . _fullLayout . _deactivateSelection ( gd ) ;
686696 }
687697
@@ -1503,13 +1513,10 @@ function getFillRangeItems(dragOptions) {
15031513}
15041514
15051515function emitSelecting ( gd , eventData ) {
1506- if ( drawMode ( gd . _fullLayout . dragmode ) ) return ;
15071516 gd . emit ( 'plotly_selecting' , eventData ) ;
15081517}
15091518
15101519function emitSelected ( gd , eventData ) {
1511- if ( drawMode ( gd . _fullLayout . dragmode ) ) return ;
1512-
15131520 if ( eventData ) {
15141521 eventData . selections = ( gd . layout || { } ) . selections || [ ] ;
15151522 }
@@ -1518,7 +1525,6 @@ function emitSelected(gd, eventData) {
15181525}
15191526
15201527function emitDeselect ( gd ) {
1521- if ( drawMode ( gd . _fullLayout . dragmode ) ) return ;
15221528 gd . emit ( 'plotly_deselect' , null ) ;
15231529}
15241530
0 commit comments