@@ -356,10 +356,12 @@ function selectOnClick(gd, numClicks, evt, xAxes, yAxes, outlines) {
356
356
searchInfo = searchTraces [ i ] ;
357
357
trace = searchInfo . cd [ 0 ] . trace ;
358
358
359
- // Start new selection if needed
360
- if ( ! retainSelection ) {
359
+ // Clear old selection if needed
360
+ if ( ! retainSelection || clearEntireSelection ) {
361
361
searchInfo . _module . toggleSelected ( searchInfo , false ) ;
362
362
if ( outlines ) outlines . remove ( ) ;
363
+
364
+ if ( clearEntireSelection ) continue ;
363
365
}
364
366
365
367
// Determine clicked points,
@@ -384,23 +386,9 @@ function selectOnClick(gd, numClicks, evt, xAxes, yAxes, outlines) {
384
386
allSelectionItems = allSelectionItems . concat ( fillSelectionItem ( traceSelection , searchInfo ) ) ;
385
387
}
386
388
387
- // TODO Use the clearEntireSelection flag now
388
- // Hack to achieve regl traces to set selectBatch to null in case no point is selected anymore
389
- // TODO check in advance if a click clear the entire selection, because in this
390
- // case just call toggleSelected(searchInfo, false) on all traces and be done. The `shouldSelect` above might
391
- // become obsolete.
392
- if ( allSelectionItems . length === 0 ) {
393
- for ( i = 0 ; i < searchTraces . length ; i ++ ) {
394
- searchTraces [ i ] . _module . toggleSelected ( searchTraces [ i ] , false ) ;
395
- }
396
- }
397
-
398
389
// Grand selection state update needs to be done once for the entire plot
399
390
eventData = { points : allSelectionItems } ;
400
391
updateSelectedState ( gd , searchTraces , eventData ) ;
401
-
402
- // Remove outlines if no point is selected anymore
403
- if ( allSelectionItems . length === 0 && outlines ) outlines . remove ( ) ;
404
392
}
405
393
406
394
function clickedPtsFor ( searchInfo , hoverData ) {
0 commit comments