Skip to content

Commit 9d0bcfd

Browse files
committed
fixup cross-subplot select logic brought up in 71a0395
1 parent 24dad16 commit 9d0bcfd

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

Diff for: src/plots/cartesian/select.js

+26-13
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,33 @@ function prepSelect(e, startX, startY, dragOptions, mode) {
5353
var filterPoly, testPoly, mergedPolygons, currentPolygon;
5454
var i, cd, trace, searchInfo, eventData;
5555

56-
if(fullLayout._lastSelectedSubplot && fullLayout._lastSelectedSubplot === plotinfo.id) {
56+
var selectingOnSameSubplot = (
57+
fullLayout._lastSelectedSubplot &&
58+
fullLayout._lastSelectedSubplot === plotinfo.id
59+
);
60+
61+
if(
62+
selectingOnSameSubplot &&
63+
(e.shiftKey || e.altKey) &&
64+
(plotinfo.selection && plotinfo.selection.polygons) &&
65+
!dragOptions.polygons
66+
) {
5767
// 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
68+
dragOptions.polygons = plotinfo.selection.polygons;
69+
dragOptions.mergedPolygons = plotinfo.selection.mergedPolygons;
70+
} else if(
71+
(!e.shiftKey && !e.altKey) ||
72+
((e.shiftKey || e.altKey) &&
73+
!plotinfo.selection)
74+
) {
75+
// create new polygons, if shift mode or selecting across different subplots
76+
plotinfo.selection = {};
77+
plotinfo.selection.polygons = dragOptions.polygons = [];
78+
plotinfo.selection.mergedPolygons = dragOptions.mergedPolygons = [];
79+
}
80+
81+
// clear selection outline when selecting a different subplot
82+
if(!selectingOnSameSubplot) {
7083
clearSelect(zoomLayer);
7184
fullLayout._lastSelectedSubplot = plotinfo.id;
7285
}

0 commit comments

Comments
 (0)