@@ -71,7 +71,7 @@ function prepSelect(e, startX, startY, dragOptions, mode) {
71
71
( ! e . shiftKey && ! e . altKey ) ||
72
72
( ( e . shiftKey || e . altKey ) && ! plotinfo . selection )
73
73
) {
74
- // create new polygons, if shift mode or selecting across different subplots
74
+ // create new polygons, if not shift mode or selecting across different subplots
75
75
plotinfo . selection = { } ;
76
76
plotinfo . selection . polygons = dragOptions . polygons = [ ] ;
77
77
plotinfo . selection . mergedPolygons = dragOptions . mergedPolygons = [ ] ;
@@ -283,7 +283,7 @@ function prepSelect(e, startX, startY, dragOptions, mode) {
283
283
for ( i = 0 ; i < searchTraces . length ; i ++ ) {
284
284
searchInfo = searchTraces [ i ] ;
285
285
286
- traceSelection = searchInfo . _module . selectPoints ( searchInfo , testPoly ) ;
286
+ traceSelection = searchInfo . _module . selectPoints ( searchInfo , testPoly , shouldRetainSelection ( e ) ) ;
287
287
traceSelections . push ( traceSelection ) ;
288
288
289
289
thisSelection = fillSelectionItem ( traceSelection , searchInfo ) ;
@@ -310,8 +310,6 @@ function prepSelect(e, startX, startY, dragOptions, mode) {
310
310
throttle . done ( throttleID ) . then ( function ( ) {
311
311
throttle . clear ( throttleID ) ;
312
312
313
- // clear visual boundaries of selection area if displayed
314
- outlines . remove ( ) ;
315
313
if ( numClicks === 2 ) {
316
314
for ( i = 0 ; i < searchTraces . length ; i ++ ) {
317
315
searchInfo = searchTraces [ i ] ;
@@ -320,6 +318,9 @@ function prepSelect(e, startX, startY, dragOptions, mode) {
320
318
321
319
updateSelectedState ( gd , searchTraces ) ;
322
320
gd . emit ( 'plotly_deselect' , null ) ;
321
+
322
+ // clear visual boundaries of selection area if displayed
323
+ outlines . remove ( ) ;
323
324
}
324
325
else {
325
326
// TODO What to do with the code below because we now have behavior for a single click
@@ -358,7 +359,6 @@ function prepSelect(e, startX, startY, dragOptions, mode) {
358
359
// ----------------
359
360
// TODO handle clearing selection when no point is clicked (based on hoverData)
360
361
// TODO do we have to consider multiple traces?
361
- // TODO implement selection retention (Shift key) for lasso and box
362
362
function selectOnClick ( gd , numClicks , evt ) {
363
363
var calcData = gd . calcdata [ 0 ] ;
364
364
@@ -374,7 +374,7 @@ function selectOnClick(gd, numClicks, evt) {
374
374
module = trace . _module ;
375
375
376
376
// Execute selection by delegating to respective module
377
- var retainSelection = evt . shiftKey ,
377
+ var retainSelection = shouldRetainSelection ( evt ) ,
378
378
pointSelected = isPointSelected ( trace , hoverDatum . pointNumber ) ,
379
379
onePointSelectedOnly = isOnePointSelectedOnly ( trace ) ;
380
380
@@ -395,6 +395,10 @@ function selectOnClick(gd, numClicks, evt) {
395
395
}
396
396
}
397
397
398
+ function shouldRetainSelection ( evt ) {
399
+ return evt . shiftKey ;
400
+ }
401
+
398
402
function isPointSelected ( trace , pointNumber ) {
399
403
if ( ! trace . selectedpoints && ! Array . isArray ( trace . selectedpoints ) ) return false ;
400
404
return trace . selectedpoints . indexOf ( pointNumber ) > - 1 ;
0 commit comments