Skip to content

Commit

Permalink
do not attempt to re-hover on exiting mapbox subplots
Browse files Browse the repository at this point in the history
  • Loading branch information
etpinard committed Oct 11, 2019
1 parent d8a0512 commit f6a47b2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/plots/mapbox/mapbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ proto.initFx = function(calcData, fullLayout) {
self.yaxis.p2c = function() { return evt.lngLat.lat; };

gd._fullLayout._rehover = function() {
if(gd._fullLayout._hoversubplot === self.id) {
if(gd._fullLayout._hoversubplot === self.id && gd._fullLayout[self.id]) {
Fx.hover(gd, evt, self.id);
}
};
Expand Down
33 changes: 33 additions & 0 deletions test/jasmine/tests/mapbox_test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var Plotly = require('@lib');
var Lib = require('@src/lib');
var Fx = require('@src/components/fx');

var constants = require('@src/plots/mapbox/constants');
var supplyLayoutDefaults = require('@src/plots/mapbox/layout_defaults');
Expand Down Expand Up @@ -1155,6 +1156,38 @@ describe('@noCI, mapbox plots', function() {
.then(done);
}, LONG_TIMEOUT_INTERVAL);

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

function countHoverLabels() {
return d3.select('.hoverlayer').selectAll('g').size();
}

Promise.resolve()
.then(function() {
return _mouseEvent('mousemove', pointPos, function() {
expect(countHoverLabels()).toEqual(1);
expect(Fx.hover).toHaveBeenCalledTimes(1);
expect(Fx.hover.calls.argsFor(0)[2]).toBe('mapbox');
Fx.hover.calls.reset();
});
})
.then(function() { return Plotly.deleteTraces(gd, [0, 1]); })
.then(delay(10))
.then(function() {
return _mouseEvent('mousemove', pointPos, function() {
expect(countHoverLabels()).toEqual(0);
// N.B. no additional calls from Plots.rehover()
// (as 'mapbox' subplot is gone),
// just one on the fallback xy subplot
expect(Fx.hover).toHaveBeenCalledTimes(1);
expect(Fx.hover.calls.argsFor(0)[2]).toBe('xy');
});
})
.catch(failTest)
.then(done);
}, LONG_TIMEOUT_INTERVAL);

it('@gl should respond drag / scroll / double-click interactions', function(done) {
var relayoutCnt = 0;
var doubleClickCnt = 0;
Expand Down

0 comments on commit f6a47b2

Please sign in to comment.