Skip to content

Commit aa53f75

Browse files
committed
Fail-safe when recomputing hover for click
1 parent 43c1181 commit aa53f75

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/plots/cartesian/graph_interact.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -1529,9 +1529,13 @@ function hoverChanged(gd, evt, oldhoverdata) {
15291529
fx.click = function(gd, evt, subplot) {
15301530
var annotationsDone = Registry.getComponentMethod('annotations', 'onClick')(gd, gd._hoverdata);
15311531

1532-
// The true flag at the end causes it to re-run the hover computation to figure out *which*
1533-
// point is being clicked. Without this, clicking is somewhat unreliable.
1534-
fx.hover(gd, evt, subplot, true);
1532+
// fallback to fail-safe in case the plot type's hover method doesn't pass the subplot.
1533+
// Ternary, for example, didn't, but it was caught because tested.
1534+
if (subplot !== undefined) {
1535+
// The true flag at the end causes it to re-run the hover computation to figure out *which*
1536+
// point is being clicked. Without this, clicking is somewhat unreliable.
1537+
fx.hover(gd, evt, subplot, true);
1538+
}
15351539

15361540
function emitClick() { gd.emit('plotly_click', {points: gd._hoverdata, event: evt}); }
15371541

0 commit comments

Comments
 (0)