fix: clamp student popover position to stay within viewport vertically

This commit is contained in:
Pontoporeia
2026-07-10 17:11:10 +02:00
parent d8f85b03ad
commit 14c21586c5
2 changed files with 11 additions and 0 deletions
+1
View File
@@ -1,3 +1,4 @@
# TODO # TODO
- [x] Fix relinked file not appearing in FilePond UI: switch to ID-based input lookup - [x] Fix relinked file not appearing in FilePond UI: switch to ID-based input lookup
- [x] Fix student name popover overflowing below viewport: clamp position so popover stays within screen bounds
@@ -15,6 +15,16 @@
if (left + 300 > window.innerWidth + window.scrollX) { if (left + 300 > window.innerWidth + window.scrollX) {
left = r.left + window.scrollX - 312; left = r.left + window.scrollX - 312;
} }
// Keep popover within viewport vertically
var popHeight = popover.offsetHeight || 300;
var viewBottom = window.innerHeight + window.scrollY;
if (top + popHeight > viewBottom) {
top = viewBottom - popHeight - 8;
// Don't shift above the viewport top
if (top < window.scrollY) {
top = window.scrollY + 8;
}
}
popover.style.left = `${left}px`; popover.style.left = `${left}px`;
popover.style.top = `${top}px`; popover.style.top = `${top}px`;
} }