Skip to content

Commit 8b959ea

Browse files
committed
emit plotly_deselect on selection removal and update subplot state
1 parent 3632827 commit 8b959ea

File tree

2 files changed

+40
-5
lines changed

2 files changed

+40
-5
lines changed

src/components/selections/select.js

+35-5
Original file line numberDiff line numberDiff line change
@@ -1116,14 +1116,13 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
11161116
var eventData = {points: allSelections};
11171117
updateSelectedState(gd, allSearchTraces, eventData);
11181118

1119+
var clickmode = fullLayout.clickmode;
1120+
var sendEvents = clickmode.indexOf('event') > -1;
1121+
11191122
if(
11201123
!plotinfo && // get called from plot_api & plots
1121-
fullLayout._reselect === true
1124+
fullLayout._reselect
11221125
) {
1123-
fullLayout._reselect = false;
1124-
1125-
var clickmode = fullLayout.clickmode;
1126-
var sendEvents = clickmode.indexOf('event') > -1;
11271126
if(sendEvents) {
11281127
var activePolygons = getLayoutPolygons(gd, true);
11291128

@@ -1142,6 +1141,37 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
11421141

11431142
gd.emit('plotly_selected', eventData);
11441143
}
1144+
1145+
fullLayout._reselect = false;
1146+
}
1147+
1148+
if(
1149+
!plotinfo && // get called from plot_api & plots
1150+
fullLayout._deselect
1151+
) {
1152+
var deselect = fullLayout._deselect;
1153+
xRef = deselect.xref;
1154+
yRef = deselect.yref;
1155+
1156+
searchTraces = determineSearchTraces(
1157+
gd,
1158+
[getFromId(gd, xRef, 'x')],
1159+
[getFromId(gd, yRef, 'y')],
1160+
xRef + yRef
1161+
);
1162+
1163+
for(var k = 0; k < searchTraces.length; k++) {
1164+
var searchInfo = searchTraces[k];
1165+
searchInfo._module.selectPoints(searchInfo, false);
1166+
}
1167+
1168+
updateSelectedState(gd, searchTraces);
1169+
1170+
if(sendEvents) {
1171+
gd.emit('plotly_deselect', eventData.points.length ? eventData : null);
1172+
}
1173+
1174+
fullLayout._deselect = false;
11451175
}
11461176

11471177
return {

src/components/shapes/display_outlines.js

+5
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,11 @@ function eraseActiveSelection(gd) {
388388

389389
delete gd._fullLayout._activeSelectionIndex;
390390

391+
gd._fullLayout._deselect = {
392+
xref: selections[id].xref,
393+
yref: selections[id].yref
394+
};
395+
391396
Registry.call('_guiRelayout', gd, {
392397
selections: list
393398
});

0 commit comments

Comments
 (0)