Skip to content

Commit

Permalink
fix: stick metrics tooltip to edge of screen (#4935)
Browse files Browse the repository at this point in the history
  • Loading branch information
abbiesims authored Dec 9, 2024
1 parent c552d80 commit 09f8c10
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions static/js/publisher/metrics/graphs/activeDevicesGraph/tooltips.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,19 @@ export function tooltips(this: any) {
.node()
.getBoundingClientRect();

const windowWidth = window.innerWidth;
let adjustedLeft = mousePosition[0] + this.margin.left;

if (tooltipBounding.right > (windowWidth - 15)) {
adjustedLeft -= (tooltipBounding.right - windowWidth) + 15;
}

if (tooltipBounding.left < 0) {
adjustedLeft -= tooltipBounding.left;
}

this.tooltip.style("left", `${adjustedLeft}px`);

if (tooltipBounding.top < 0) {
this.tooltip
.select(".p-tooltip")
Expand Down

0 comments on commit 09f8c10

Please sign in to comment.