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
3 changed files with 53 additions and 2 deletions

View file

@ -0,0 +1,17 @@
// Where a table's filter popover sits. Run by `npm test`, which Node runs
// with its built-in test runner and type stripping, so the `.ts` module is
// imported as it is.
import assert from "node:assert/strict";
import { test } from "node:test";
import { clampLeft } from "../src/ui/table/popover-position.ts";
test("a popover near the right edge is pulled back on screen", () => {
// 300 wide in a 1000 wide window: the right edge may reach 992.
assert.equal(clampLeft(900, 300, 1000), 692);
assert.equal(clampLeft(100, 300, 1000), 100);
});
test("a popover never goes past the left edge", () => {
assert.equal(clampLeft(5, 300, 1000), 8);
assert.equal(clampLeft(50, 2000, 1000), 8);
});