Webapp: Last 3 months evidence range, keep popovers on screen

Evidence pack gets a Last 3 months quick range (three full calendar
months). Opened menus are nudged back inside the window, so header
popovers no longer start off-screen on phones or a wrapped header.
Buttons and filter pills inside a menu keep their own styling.
This commit is contained in:
cproudlock
2026-10-14 15:12:38 -04:00
parent 2dbaaded44
commit 4db9dc093f
3 changed files with 18 additions and 2 deletions

View File

@@ -510,3 +510,17 @@ document.addEventListener('keydown', function (e) {
if (s && d.contains(document.activeElement)) s.focus();
});
});
// Keep an opened menu inside the window: a right-aligned menu under a button
// near the left edge (a wrapped page header, a phone) would start off-screen.
document.addEventListener('toggle', function (e) {
var d = e.target;
if (!d.matches || !d.matches('details.more') || !d.open) return;
var m = d.querySelector('.menu');
if (!m) return;
m.style.transform = '';
var r = m.getBoundingClientRect(), pad = 8, dx = 0;
if (r.left < pad) dx = pad - r.left;
else if (r.right > window.innerWidth - pad) dx = window.innerWidth - pad - r.right;
if (dx) m.style.transform = 'translateX(' + Math.round(dx) + 'px)';
}, true);