Skip to content

Commit 974cebf

Browse files
committed
put back in the plotly_selected->undefined event
to be removed for good in v2
1 parent 149dd74 commit 974cebf

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/plots/cartesian/select.js

+5
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,11 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
273273
updateSelectedState(gd, searchTraces);
274274
gd.emit('plotly_deselect', null);
275275
}
276+
else {
277+
// TODO: remove in v2 - this was probably never intended to work as it does,
278+
// but in case anyone depends on it we don't want to break it now.
279+
gd.emit('plotly_selected', undefined);
280+
}
276281
});
277282
};
278283

test/jasmine/tests/select_test.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,16 @@ function assertEventCounts(selecting, selected, deselect, msg) {
9696
expect(deselectCnt).toBe(deselect, 'plotly_deselect call count: ' + msg);
9797
}
9898

99+
// TODO: in v2, when we get rid of the `plotly_selected->undefined` event, these will
100+
// change to BOXEVENTS = [1, 1, 1], LASSOEVENTS = [4, 1, 1]. See also _run down below
101+
//
99102
// events for box or lasso select mouse moves then a doubleclick
100103
var NOEVENTS = [0, 0, 0];
101104
// deselect used to give an extra plotly_selected event on the first click
102105
// with undefined event data - but now that's gone, since `clickFn` handles this.
103-
var BOXEVENTS = [1, 1, 1];
106+
var BOXEVENTS = [1, 2, 1];
104107
// assumes 5 points in the lasso path
105-
var LASSOEVENTS = [4, 1, 1];
108+
var LASSOEVENTS = [4, 2, 1];
106109

107110
describe('Test select box and lasso in general:', function() {
108111
var mock = require('@mocks/14.json');
@@ -643,7 +646,11 @@ describe('Test select box and lasso per trace:', function() {
643646
return (eventCounts[0] ? selectedPromise : Promise.resolve())
644647
.then(afterDragFn)
645648
.then(function() {
646-
assertEventCounts(eventCounts[0], eventCounts[1], 0, msg + ' (before dblclick)');
649+
// TODO: in v2 when we remove the `plotly_selecting->undefined` the Math.max(...)
650+
// in the middle here will turn into just eventCounts[1].
651+
// It's just here because one of the selected events is generated during
652+
// doubleclick so hasn't happened yet when we're testing this.
653+
assertEventCounts(eventCounts[0], Math.max(0, eventCounts[1] - 1), 0, msg + ' (before dblclick)');
647654
return doubleClick(dblClickPos[0], dblClickPos[1]);
648655
})
649656
.then(eventCounts[2] ? deselectPromise : Promise.resolve())

0 commit comments

Comments
 (0)