Skip to content

Commit

Permalink
fix: tooltip positioning near edge
Browse files Browse the repository at this point in the history
  • Loading branch information
rpenido committed Nov 14, 2024
1 parent 0444f71 commit bd5a05b
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 bd5a05b

Please sign in to comment.