Skip to content

Commit

Permalink
[lint addon] Make sure tooltips don't stick out of the window width
Browse files Browse the repository at this point in the history
Issue #7044
  • Loading branch information
marijnh committed Jul 21, 2023
1 parent 82ce3d2 commit 370f7c4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions addon/lint/lint.js
Expand Up @@ -24,8 +24,10 @@

function position(e) {
if (!tt.parentNode) return CodeMirror.off(document, "mousemove", position);
tt.style.top = Math.max(0, e.clientY - tt.offsetHeight - 5) + "px";
tt.style.left = (e.clientX + 5) + "px";
var top = Math.max(0, e.clientY - tt.offsetHeight - 5);
var left = Math.max(0, Math.min(e.clientX + 5, tt.ownerDocument.defaultView.innerWidth - tt.offsetWidth));
tt.style.top = top + "px"
tt.style.left = left + "px";
}
CodeMirror.on(document, "mousemove", position);
position(e);
Expand Down

0 comments on commit 370f7c4

Please sign in to comment.