Skip to content

Commit 7f0163e

Browse files
committed
strict subplot test to detect zero subplot e.g. sankey in determineSearchTraces & fix 6264
1 parent a4038e3 commit 7f0163e

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/components/selections/select.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,14 @@ var p2r = helpers.p2r;
5050
var axValue = helpers.axValue;
5151
var getTransform = helpers.getTransform;
5252

53+
function cartesianDrag(dragOptions) {
54+
// N.B. subplot may be falsy e.g zero sankey index!
55+
return dragOptions.subplot !== undefined;
56+
}
57+
5358
function prepSelect(evt, startX, startY, dragOptions, mode) {
59+
var isCartesianDrag = cartesianDrag(dragOptions);
60+
5461
var isFreeMode = freeMode(mode);
5562
var isRectMode = rectMode(mode);
5663
var isOpenMode = openMode(mode);
@@ -64,7 +71,7 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
6471
var gd = dragOptions.gd;
6572
var fullLayout = gd._fullLayout;
6673
var immediateSelect = isSelectMode && fullLayout.newselection.mode === 'immediate' &&
67-
!dragOptions.subplot; // N.B. only cartesian subplots have persistent selection
74+
!isCartesianDrag; // N.B. only cartesian subplots have persistent selection
6875

6976
var zoomLayer = fullLayout._zoomlayer;
7077
var dragBBox = dragOptions.element.getBoundingClientRect();
@@ -112,7 +119,7 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
112119
opacity: isDrawMode ? newStyle.opacity / 2 : 1,
113120
fill: (isDrawMode && !isOpenMode) ? newStyle.fillcolor : 'none',
114121
stroke: newStyle.line.color || (
115-
dragOptions.subplot !== undefined ?
122+
isCartesianDrag ?
116123
'#7f7f7f' : // non-cartesian subplot
117124
Color.contrast(gd._fullLayout.plot_bgcolor) // cartesian subplot
118125
),
@@ -145,6 +152,8 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
145152

146153
if(immediateSelect && !evt.shiftKey) {
147154
dragOptions._clearSubplotSelections = function() {
155+
if(isCartesianDrag) return;
156+
148157
var xRef = xAxis._id;
149158
var yRef = yAxis._id;
150159
deselectSubplot(gd, xRef, yRef, searchTraces);
@@ -709,7 +718,7 @@ function clearSelectionsCache(dragOptions, immediateSelect) {
709718
var selections;
710719
if(
711720
isSelectMode &&
712-
!dragOptions.subplot // only allow cartesian - no mapbox for now
721+
!cartesianDrag(dragOptions) // only allow cartesian - no mapbox for now
713722
) {
714723
selections = newSelections(outlines, dragOptions);
715724
}
@@ -748,7 +757,10 @@ function determineSearchTraces(gd, xAxes, yAxes, subplot) {
748757

749758
if(trace.visible !== true || !trace._module || !trace._module.selectPoints) continue;
750759

751-
if(subplot && (trace.subplot === subplot || trace.geo === subplot)) {
760+
if(
761+
cartesianDrag({subplot: subplot}) &&
762+
(trace.subplot === subplot || trace.geo === subplot)
763+
) {
752764
searchTraces.push(createSearchInfo(trace._module, cd, xAxes[0], yAxes[0]));
753765
} else if(trace.type === 'splom') {
754766
// FIXME: make sure we don't have more than single axis for splom

0 commit comments

Comments
 (0)