Watch
0
0
Fork
You've already forked hyperhive
0

swarm-ui: keep the table filter popover inside the window

This commit is contained in:
iris 2026-10-21 21:13:13 +02:00 • committed by mara
commit 16c9e0ae3b

View file

@ -0,0 +1,19 @@
// Where a table's filter popover sits, without a DOM.
// Space kept between a floating box and the viewport's edge.
export const POPOVER_EDGE_PX = 8;
/**
* The left edge for a popover of `width` that wants to start at `left`:
* pulled in so its right edge stays on screen, but never past the left edge.
* A filterable column near the right of the window would otherwise open
* partly outside it.
*/
export function clampLeft(
left: number,
width: number,
viewportWidth: number,
): number {
const maxLeft = viewportWidth - width - POPOVER_EDGE_PX;
return Math.max(POPOVER_EDGE_PX, Math.min(left, maxLeft));
}