Skip to content

Commit 6347b0d

Browse files
committed
do not attempt to re-hover on exiting subplots
1 parent 25fe1c9 commit 6347b0d

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

src/plots/cartesian/graph_interact.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ exports.initInteractions = function initInteractions(gd) {
5959
// This is on `gd._fullLayout`, *not* fullLayout because the reference
6060
// changes by the time this is called again.
6161
gd._fullLayout._rehover = function() {
62-
if(gd._fullLayout._hoversubplot === subplot) {
62+
if((gd._fullLayout._hoversubplot === subplot) && gd._fullLayout._plots[subplot]) {
6363
Fx.hover(gd, evt, subplot);
6464
}
6565
};

test/jasmine/tests/hover_label_test.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2607,6 +2607,56 @@ describe('hover updates', function() {
26072607
})
26082608
.then(done);
26092609
});
2610+
2611+
it('should not attempt to rehover over exiting subplots', function(done) {
2612+
spyOn(Fx, 'hover').and.callThrough();
2613+
2614+
var data = [
2615+
{y: [1], hoverinfo: 'y'},
2616+
{y: [2], hoverinfo: 'y', xaxis: 'x2', yaxis: 'y2'}
2617+
];
2618+
2619+
var data2 = [
2620+
{y: [1], hoverinfo: 'y'}
2621+
];
2622+
2623+
var layout = {
2624+
xaxis: {domain: [0, 0.5]},
2625+
xaxis2: {anchor: 'y2', domain: [0.5, 1]},
2626+
yaxis2: {anchor: 'x2'},
2627+
width: 400,
2628+
height: 200,
2629+
margin: {l: 0, t: 0, r: 0, b: 0},
2630+
showlegend: false
2631+
};
2632+
2633+
var gd = createGraphDiv();
2634+
var onPt2 = [300, 100];
2635+
var offPt2 = [250, 100];
2636+
2637+
Plotly.react(gd, data, layout)
2638+
.then(function() {
2639+
assertLabelsCorrect(onPt2, [303, 100], '2', 'after 1st draw [on-pt]');
2640+
assertLabelsCorrect(offPt2, null, null, 'after 1st draw [off-pt]');
2641+
expect(Fx.hover).toHaveBeenCalledTimes(2);
2642+
})
2643+
.then(function() {
2644+
var promise = Plotly.react(gd, data2, layout);
2645+
assertLabelsCorrect(onPt2, null, null, '2', 'before react() resolves [on-pt]');
2646+
assertLabelsCorrect(offPt2, null, null, 'before react() resolves [off-pt]');
2647+
// N.B. no calls from Plots.rehover() as x2y2 subplot got removed!
2648+
expect(Fx.hover).toHaveBeenCalledTimes(2);
2649+
return promise;
2650+
})
2651+
.then(function() {
2652+
expect(Fx.hover).toHaveBeenCalledTimes(2);
2653+
assertLabelsCorrect(onPt2, null, null, '2', 'after react() resolves [on-pt]');
2654+
assertLabelsCorrect(offPt2, null, null, 'after react() resolves [off-pt]');
2655+
expect(Fx.hover).toHaveBeenCalledTimes(2);
2656+
})
2657+
.catch(failTest)
2658+
.then(done);
2659+
});
26102660
});
26112661

26122662
describe('Test hover label custom styling:', function() {

0 commit comments

Comments
 (0)