Skip to content

Commit

Permalink
fix: tooltip positioning near edge [FC-0062] (#35848)
Browse files Browse the repository at this point in the history
Fixes the tooltip positioning rule to avoid rendering it outside the window/iframe.
  • Loading branch information
rpenido authored Nov 15, 2024
1 parent cb1e6ee commit 842aec4
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions common/static/js/src/tooltip_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,20 @@
},

getCoords: function(pageX, pageY) {
let left = pageX - 0.5 * this.tooltip.outerWidth();
const top = pageY - (this.tooltip.outerHeight() + 15);
// Check if the tooltip is going off the right edge of the screen
if (left + this.tooltip.outerWidth() > window.innerWidth) {
left = window.innerWidth - this.tooltip.outerWidth();
}
// Check if the tooltip is going off the left edge of the screen
if (left < 0) {
left = 0;
}

return {
left: pageX - 0.5 * this.tooltip.outerWidth(),
top: pageY - (this.tooltip.outerHeight() + 15)
left,
top,
};
},

Expand Down

0 comments on commit 842aec4

Please sign in to comment.