Skip to content

Commit e460e46

Browse files
committed
Simplify code for coercing selection cache state [1852]
1 parent 61b1a32 commit e460e46

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/plots/cartesian/select.js

+4-11
Original file line numberDiff line numberDiff line change
@@ -372,20 +372,13 @@ function coerceSelectionsCache(evt, gd, dragOptions) {
372372
fullLayout._lastSelectedSubplot &&
373373
fullLayout._lastSelectedSubplot === plotinfo.id
374374
);
375-
376-
if(
377-
selectingOnSameSubplot &&
378-
(evt.shiftKey || evt.altKey) &&
379-
(plotinfo.selection && plotinfo.selection.selectionDefs) &&
380-
!dragOptions.selectionDefs
381-
) {
375+
var hasModifierKey = evt.shiftKey || evt.altKey;
376+
if(selectingOnSameSubplot && hasModifierKey &&
377+
(plotinfo.selection && plotinfo.selection.selectionDefs) && !dragOptions.selectionDefs) {
382378
// take over selection definitions from prev mode, if any
383379
dragOptions.selectionDefs = plotinfo.selection.selectionDefs;
384380
dragOptions.mergedPolygons = plotinfo.selection.mergedPolygons;
385-
} else if(
386-
(!evt.shiftKey && !evt.altKey) ||
387-
((evt.shiftKey || evt.altKey) && !plotinfo.selection)
388-
) {
381+
} else if(!hasModifierKey || !plotinfo.selection) {
389382
clearSelectionsCache(dragOptions);
390383
}
391384

0 commit comments

Comments
 (0)