@@ -53,35 +53,28 @@ function prepSelect(e, startX, startY, dragOptions, mode) {
5353 var filterPoly , testPoly , mergedPolygons , currentPolygon ;
5454 var i , cd , trace , searchInfo , eventData ;
5555
56- // take over selection polygons from prev mode, if any
57- if ( ( e . shiftKey || e . altKey ) && ( plotinfo . selection && plotinfo . selection . polygons ) && ! dragOptions . polygons ) {
58- dragOptions . polygons = plotinfo . selection . polygons ;
59- dragOptions . mergedPolygons = plotinfo . selection . mergedPolygons ;
60- }
61- // create new polygons, if shift mode
62- else if ( ( ! e . shiftKey && ! e . altKey ) || ( ( e . shiftKey || e . altKey ) && ! plotinfo . selection ) ) {
63- plotinfo . selection = { } ;
64- plotinfo . selection . polygons = dragOptions . polygons = [ ] ;
65- plotinfo . selection . mergedPolygons = dragOptions . mergedPolygons = [ ] ;
56+ if ( fullLayout . _lastSelectedSubplot && fullLayout . _lastSelectedSubplot === plotinfo . id ) {
57+ // take over selection polygons from prev mode, if any
58+ if ( ( e . shiftKey || e . altKey ) && ( plotinfo . selection && plotinfo . selection . polygons ) && ! dragOptions . polygons ) {
59+ dragOptions . polygons = plotinfo . selection . polygons ;
60+ dragOptions . mergedPolygons = plotinfo . selection . mergedPolygons ;
61+ }
62+ // create new polygons, if shift mode
63+ else if ( ( ! e . shiftKey && ! e . altKey ) || ( ( e . shiftKey || e . altKey ) && ! plotinfo . selection ) ) {
64+ plotinfo . selection = { } ;
65+ plotinfo . selection . polygons = dragOptions . polygons = [ ] ;
66+ plotinfo . selection . mergedPolygons = dragOptions . mergedPolygons = [ ] ;
67+ }
68+ } else {
69+ // do not allow multi-selection across different subplots
70+ clearSelect ( zoomLayer ) ;
71+ fullLayout . _lastSelectedSubplot = plotinfo . id ;
6672 }
6773
6874 if ( mode === 'lasso' ) {
6975 filterPoly = filteredPolygon ( [ [ x0 , y0 ] ] , constants . BENDPX ) ;
7076 }
7177
72- // FIXME: find a better way to clear selection outlines for splom
73- if ( ! e . shiftKey && ! e . altKey ) {
74- for ( i = 0 ; i < gd . calcdata . length ; i ++ ) {
75- cd = gd . calcdata [ i ] ;
76- trace = cd [ 0 ] . trace ;
77-
78- if ( trace . type === 'splom' ) {
79- zoomLayer . selectAll ( '.select-outline' ) . remove ( ) ;
80- break ;
81- }
82- }
83- }
84-
8578 var outlines = zoomLayer . selectAll ( 'path.select-outline-' + plotinfo . id ) . data ( [ 1 , 2 ] ) ;
8679
8780 outlines . enter ( )
@@ -365,11 +358,9 @@ function updateSelectedState(gd, searchTraces, eventData) {
365358 delete trace . selectedpoints ;
366359 delete trace . _input . selectedpoints ;
367360 }
368-
369- // FIXME: make sure there is no better way to clear selection for sploms
370- gd . _fullLayout . _zoomlayer . selectAll ( '.select-outline' ) . remove ( ) ;
371361 }
372362
363+ // group searchInfo traces by trace modules
373364 var lookup = { } ;
374365
375366 for ( i = 0 ; i < searchTraces . length ; i ++ ) {
0 commit comments