Skip to content

Commit

Permalink
Always render tooltip inside of viewport
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminr-ps committed Jun 29, 2023
1 parent 9974ded commit 7cf7f83
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions addon/lint/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
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 box = tt.getBoundingClientRect()
var parentView = tt.ownerDocument.defaultView
if ( tt.offsetLeft + box.width > parentView.innerWidth)
{
tt.style.left = tt.offsetLeft - box.width
}
}
CodeMirror.on(document, "mousemove", position);
position(e);
Expand Down

1 comment on commit 7cf7f83

@benjaminr-ps
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following shows, if the linter's tooltip is exceeding the viewport:
image

The following shows the fixed version:
image

This is a very quick solution, fixing that particular corner case, shown in the screenshot.
Or course, we would appreciate a more mature solution to this problem in general.

Please sign in to comment.