Skip to content
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

Do not attempt to re-hover on exiting subplots #4269

Merged
merged 4 commits into from
Oct 15, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/plots/cartesian/graph_interact.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ exports.initInteractions = function initInteractions(gd) {
// This is on `gd._fullLayout`, *not* fullLayout because the reference
// changes by the time this is called again.
gd._fullLayout._rehover = function() {
if(gd._fullLayout._hoversubplot === subplot) {
if((gd._fullLayout._hoversubplot === subplot) && gd._fullLayout._plots[subplot]) {
Fx.hover(gd, evt, subplot);
}
};
Expand Down
50 changes: 50 additions & 0 deletions test/jasmine/tests/hover_label_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2607,6 +2607,56 @@ describe('hover updates', function() {
})
.then(done);
});

it('should not attempt to rehover over exiting subplots', function(done) {
spyOn(Fx, 'hover').and.callThrough();

var data = [
{y: [1], hoverinfo: 'y'},
{y: [2], hoverinfo: 'y', xaxis: 'x2', yaxis: 'y2'}
];

var data2 = [
{y: [1], hoverinfo: 'y'}
];

var layout = {
xaxis: {domain: [0, 0.5]},
xaxis2: {anchor: 'y2', domain: [0.5, 1]},
yaxis2: {anchor: 'x2'},
width: 400,
height: 200,
margin: {l: 0, t: 0, r: 0, b: 0},
showlegend: false
};

var gd = createGraphDiv();
var onPt2 = [300, 100];
var offPt2 = [250, 100];

Plotly.react(gd, data, layout)
.then(function() {
assertLabelsCorrect(onPt2, [303, 100], '2', 'after 1st draw [on-pt]');
assertLabelsCorrect(offPt2, null, null, 'after 1st draw [off-pt]');
expect(Fx.hover).toHaveBeenCalledTimes(2);
})
.then(function() {
var promise = Plotly.react(gd, data2, layout);
assertLabelsCorrect(onPt2, null, null, '2', 'before react() resolves [on-pt]');
assertLabelsCorrect(offPt2, null, null, 'before react() resolves [off-pt]');
// N.B. no calls from Plots.rehover() as x2y2 subplot got removed!
expect(Fx.hover).toHaveBeenCalledTimes(2);
return promise;
})
.then(function() {
expect(Fx.hover).toHaveBeenCalledTimes(2);
assertLabelsCorrect(onPt2, null, null, '2', 'after react() resolves [on-pt]');
assertLabelsCorrect(offPt2, null, null, 'after react() resolves [off-pt]');
expect(Fx.hover).toHaveBeenCalledTimes(2);
})
.catch(failTest)
.then(done);
});
});

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