Skip to content

Avoid attaching selections to missing eventData #6260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions draftlogs/6260_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Avoid attaching selections to missing eventData (regression introduced in 2.13.0) [[#6260](https://github.com/plotly/plotly.js/pull/6260)]
12 changes: 8 additions & 4 deletions src/components/selections/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,6 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
dragOptions.doneFnCompleted(selection);
}

eventData.selections = gd.layout.selections;
emitSelected(gd, eventData);
}).catch(Lib.error);
};
Expand Down Expand Up @@ -530,7 +529,6 @@ function selectOnClick(evt, gd, xAxes, yAxes, subplot, dragOptions, polygonOutli
}

if(sendEvents) {
eventData.selections = gd.layout.selections;
emitSelected(gd, eventData);
}
}
Expand Down Expand Up @@ -1195,7 +1193,6 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
fillRangeItems(eventData, poly);
}

eventData.selections = gd.layout.selections;
emitSelected(gd, eventData);
}

Expand All @@ -1216,7 +1213,6 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {

if(sendEvents) {
if(eventData.points.length) {
eventData.selections = gd.layout.selections;
emitSelected(gd, eventData);
} else {
gd.emit('plotly_deselect', null);
Expand Down Expand Up @@ -1507,14 +1503,22 @@ function getFillRangeItems(dragOptions) {
}

function emitSelecting(gd, eventData) {
if(drawMode(gd._fullLayout.dragmode)) return;
gd.emit('plotly_selecting', eventData);
}

function emitSelected(gd, eventData) {
if(drawMode(gd._fullLayout.dragmode)) return;

if(eventData) {
eventData.selections = (gd.layout || {}).selections || [];
}

gd.emit('plotly_selected', eventData);
}

function emitDeselect(gd) {
if(drawMode(gd._fullLayout.dragmode)) return;
gd.emit('plotly_deselect', null);
}

Expand Down