Skip to content

Commit c32d32d

Browse files
committed
fix selectedpoints clearance under select/lasso drag modes
1 parent 4260df1 commit c32d32d

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

src/traces/scattergl/index.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,8 @@ function plot(gd, subplot, cdata) {
468468
}
469469

470470
var selectMode = dragmode === 'lasso' || dragmode === 'select';
471+
scene.selectBatch = null;
472+
scene.unselectBatch = null;
471473

472474
// provide viewport and range
473475
var vpRange = cdata.map(function(cdscatter) {
@@ -500,8 +502,10 @@ function plot(gd, subplot, cdata) {
500502
if(trace.selectedpoints || selectMode) {
501503
if(!selectMode) selectMode = true;
502504

503-
if(!scene.selectBatch) scene.selectBatch = [];
504-
if(!scene.unselectBatch) scene.unselectBatch = [];
505+
if(!scene.selectBatch) {
506+
scene.selectBatch = [];
507+
scene.unselectBatch = [];
508+
}
505509

506510
// regenerate scene batch, if traces number changed during selection
507511
if(trace.selectedpoints) {

test/jasmine/tests/gl2d_plot_interact_test.js

+39-2
Original file line numberDiff line numberDiff line change
@@ -809,11 +809,48 @@ describe('@gl Test gl2d plots', function() {
809809
var scene = gd._fullLayout._plots.xy._scene;
810810

811811
expect(scene.count).toBe(2);
812-
expect(scene.selectBatch).toBeDefined();
813-
expect(scene.unselectBatch).toBeDefined();
812+
expect(scene.selectBatch).toEqual([[0]]);
813+
expect(scene.unselectBatch).toEqual([[]]);
814814
expect(scene.markerOptions.length).toBe(2);
815815
expect(scene.markerOptions[1].color).toEqual(new Uint8Array([255, 0, 0, 255]));
816816
expect(scene.scatter2d.draw).toHaveBeenCalled();
817+
818+
return Plotly.restyle(gd, 'selectedpoints', null);
819+
})
820+
.then(function() {
821+
var scene = gd._fullLayout._plots.xy._scene;
822+
var msg = 'clearing under dragmode select';
823+
824+
expect(scene.selectBatch).toEqual([], msg);
825+
expect(scene.unselectBatch).toEqual([], msg);
826+
827+
// scattergl uses different pathways for select/lasso & zoom/pan
828+
return Plotly.relayout(gd, 'dragmode', 'pan');
829+
})
830+
.then(function() {
831+
var scene = gd._fullLayout._plots.xy._scene;
832+
var msg = 'cleared under dragmode pan';
833+
834+
expect(scene.selectBatch).toEqual([], msg);
835+
expect(scene.unselectBatch).toEqual([], msg);
836+
837+
return Plotly.restyle(gd, 'selectedpoints', [[1, 2], [0]]);
838+
})
839+
.then(function() {
840+
var scene = gd._fullLayout._plots.xy._scene;
841+
var msg = 'selecting via API under dragmode pan';
842+
843+
expect(scene.selectBatch).toEqual([[1, 2], [0]], msg);
844+
expect(scene.unselectBatch).toEqual([[0], []], msg);
845+
846+
return Plotly.restyle(gd, 'selectedpoints', null);
847+
})
848+
.then(function() {
849+
var scene = gd._fullLayout._plots.xy._scene;
850+
var msg = 'clearing under dragmode pan';
851+
852+
expect(scene.selectBatch).toBe(null, msg);
853+
expect(scene.unselectBatch).toBe(null, msg);
817854
})
818855
.catch(fail)
819856
.then(done);

0 commit comments

Comments
 (0)