Skip to content

Handle case of div with zero dimension when positioning unified hover box #5913

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

Merged
merged 14 commits into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from 13 commits
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: 2 additions & 0 deletions draftlogs/5913_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Handle the case of div with zero (width or) height when positioning unified hover box
(regression introduced in 2.3.0) [[#5913](https://github.com/plotly/plotly.js/pull/5913)]
12 changes: 4 additions & 8 deletions src/components/fx/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,12 @@ exports.loneHover = function loneHover(hoverItems, opts) {
};
});

var container3 = d3.select(opts.container);
var outerContainer3 = opts.outerContainer ? d3.select(opts.outerContainer) : container3;

var fullOpts = {
hovermode: 'closest',
rotateLabels: false,
bgColor: opts.bgColor || Color.background,
container: container3,
outerContainer: outerContainer3
container: d3.select(opts.container),
outerContainer: opts.outerContainer || opts.container
};

var hoverLabel = createHoverText(pointsData, fullOpts, gd);
Expand Down Expand Up @@ -657,7 +654,6 @@ function _hover(gd, evt, subplot, noHoverEvent) {
var spikelineOpts = {
fullLayout: fullLayout,
container: fullLayout._hoverlayer,
outerContainer: fullLayout._paperdiv,
event: evt
};
var oldspikepoints = gd._spikepoints;
Expand Down Expand Up @@ -831,7 +827,7 @@ function _hover(gd, evt, subplot, noHoverEvent) {
rotateLabels: rotateLabels,
bgColor: bgColor,
container: fullLayout._hoverlayer,
outerContainer: fullLayout._paperdiv,
outerContainer: fullLayout._paper.node(),
commonLabelOpts: fullLayout.hoverlabel,
hoverdistance: fullLayout.hoverdistance
};
Expand Down Expand Up @@ -894,7 +890,7 @@ function createHoverText(hoverData, opts, gd) {
var ya = c0.ya;
var axLetter = hovermode.charAt(0);
var t0 = c0[axLetter + 'Label'];
var outerContainerBB = outerContainer.node().getBoundingClientRect();
var outerContainerBB = outerContainer.getBoundingClientRect();
var outerTop = outerContainerBB.top;
var outerWidth = outerContainerBB.width;
var outerHeight = outerContainerBB.height;
Expand Down