swarm-ui: keep the table filter popover inside the window
This commit is contained in:
parent
c2f17799fc
commit
16c9e0ae3b
3 changed files with 53 additions and 2 deletions
17
frontend/packages/swarm-ui/test/popover-position.test.mjs
Normal file
17
frontend/packages/swarm-ui/test/popover-position.test.mjs
Normal 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);
|
||||
});
|
||||
Loading…
Reference in a new issue