From 5a50ff006c5aa817afb62b2f2487d8771fc69ec4 Mon Sep 17 00:00:00 2001 From: Mojtaba Samimi Date: Thu, 14 Jul 2022 15:21:53 -0400 Subject: [PATCH 1/3] fix issue 6259 - handle missing eventData, layout and selections --- src/components/selections/select.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/selections/select.js b/src/components/selections/select.js index cafe1394a32..a6b04ef2e78 100644 --- a/src/components/selections/select.js +++ b/src/components/selections/select.js @@ -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); }; @@ -530,7 +529,6 @@ function selectOnClick(evt, gd, xAxes, yAxes, subplot, dragOptions, polygonOutli } if(sendEvents) { - eventData.selections = gd.layout.selections; emitSelected(gd, eventData); } } @@ -1195,7 +1193,6 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) { fillRangeItems(eventData, poly); } - eventData.selections = gd.layout.selections; emitSelected(gd, eventData); } @@ -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); @@ -1511,6 +1507,10 @@ function emitSelecting(gd, eventData) { } function emitSelected(gd, eventData) { + if(eventData) { + eventData.selections = (gd.layout || {}).selections || []; + } + gd.emit('plotly_selected', eventData); } From 0b00ed9af661184d983a75dfa6c950c24bedafb7 Mon Sep 17 00:00:00 2001 From: Mojtaba Samimi Date: Thu, 14 Jul 2022 15:35:17 -0400 Subject: [PATCH 2/3] draft log for PR 6260 --- draftlogs/6260_fix.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 draftlogs/6260_fix.md diff --git a/draftlogs/6260_fix.md b/draftlogs/6260_fix.md new file mode 100644 index 00000000000..caf1c11fa08 --- /dev/null +++ b/draftlogs/6260_fix.md @@ -0,0 +1 @@ + - Avoid attaching selections to missing eventData (regression introduced in 2.13.0) [[#6260](https://github.com/plotly/plotly.js/pull/6260)] From 0afa52cd0df325e04d0b35b298fa565ff2122d88 Mon Sep 17 00:00:00 2001 From: Mojtaba Samimi Date: Thu, 14 Jul 2022 15:52:36 -0400 Subject: [PATCH 3/3] avoid emitting select events using shape drawing dragmodes --- src/components/selections/select.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/selections/select.js b/src/components/selections/select.js index a6b04ef2e78..1ec463183b4 100644 --- a/src/components/selections/select.js +++ b/src/components/selections/select.js @@ -1503,10 +1503,13 @@ 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 || []; } @@ -1515,6 +1518,7 @@ function emitSelected(gd, eventData) { } function emitDeselect(gd) { + if(drawMode(gd._fullLayout.dragmode)) return; gd.emit('plotly_deselect', null); }