Skip to content

Commit f6a47b2

Browse files
committed
do not attempt to re-hover on exiting mapbox subplots
1 parent d8a0512 commit f6a47b2

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/plots/mapbox/mapbox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ proto.initFx = function(calcData, fullLayout) {
475475
self.yaxis.p2c = function() { return evt.lngLat.lat; };
476476

477477
gd._fullLayout._rehover = function() {
478-
if(gd._fullLayout._hoversubplot === self.id) {
478+
if(gd._fullLayout._hoversubplot === self.id && gd._fullLayout[self.id]) {
479479
Fx.hover(gd, evt, self.id);
480480
}
481481
};

test/jasmine/tests/mapbox_test.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var Plotly = require('@lib');
22
var Lib = require('@src/lib');
3+
var Fx = require('@src/components/fx');
34

45
var constants = require('@src/plots/mapbox/constants');
56
var supplyLayoutDefaults = require('@src/plots/mapbox/layout_defaults');
@@ -1155,6 +1156,38 @@ describe('@noCI, mapbox plots', function() {
11551156
.then(done);
11561157
}, LONG_TIMEOUT_INTERVAL);
11571158

1159+
it('@gl should not attempt to rehover over exiting subplots', function(done) {
1160+
spyOn(Fx, 'hover').and.callThrough();
1161+
1162+
function countHoverLabels() {
1163+
return d3.select('.hoverlayer').selectAll('g').size();
1164+
}
1165+
1166+
Promise.resolve()
1167+
.then(function() {
1168+
return _mouseEvent('mousemove', pointPos, function() {
1169+
expect(countHoverLabels()).toEqual(1);
1170+
expect(Fx.hover).toHaveBeenCalledTimes(1);
1171+
expect(Fx.hover.calls.argsFor(0)[2]).toBe('mapbox');
1172+
Fx.hover.calls.reset();
1173+
});
1174+
})
1175+
.then(function() { return Plotly.deleteTraces(gd, [0, 1]); })
1176+
.then(delay(10))
1177+
.then(function() {
1178+
return _mouseEvent('mousemove', pointPos, function() {
1179+
expect(countHoverLabels()).toEqual(0);
1180+
// N.B. no additional calls from Plots.rehover()
1181+
// (as 'mapbox' subplot is gone),
1182+
// just one on the fallback xy subplot
1183+
expect(Fx.hover).toHaveBeenCalledTimes(1);
1184+
expect(Fx.hover.calls.argsFor(0)[2]).toBe('xy');
1185+
});
1186+
})
1187+
.catch(failTest)
1188+
.then(done);
1189+
}, LONG_TIMEOUT_INTERVAL);
1190+
11581191
it('@gl should respond drag / scroll / double-click interactions', function(done) {
11591192
var relayoutCnt = 0;
11601193
var doubleClickCnt = 0;

0 commit comments

Comments
 (0)