Skip to content

Commit dd46679

Browse files
authored
fix(ui): the dashboard's search box no longer runs under the avatar on tablets (#373)
On a tablet-sized window, the admin dashboard's search box ran under the avatar in the top bar, again. Nothing tested the top bar's layout, so earlier fixes didn't stick. Between 601px and 860px wide, `narrow.css` capped the search form at half of its row while the input kept its 10rem minimum from `base.css`, so the box spilled out of its form and under the avatar. Now: - the form keeps the `min(320px, 40vw)` width it has on wide windows; - `.search-box input` gets `min-width: 0`, so the box always fits its form. The Grant administrator page's search uses `.search-box` too, and its input now also shrinks with its label instead of spilling out on narrow screens. `admin.spec.ts` gains a test that checks, at every window size the layout spec uses (320, 768, 1280 and 1920px), that the top bar's crumb, search box and avatar don't overlap and the page doesn't scroll sideways. `viewports` and `scrollsSideways` moved to `helpers.ts` so both specs share them. Proof: the new test failed against a piqueld preview with the old stylesheet (`tablet: search crosses avatar`), then passed against a preview with the fix, alongside `layout.spec.ts`. A static check with the real stylesheet found no overlap from 300px to 1400px wide. Reviewed with review-loop: 1 round with 2× GPT 6.1 Sol and Claude Opus 5.5. Verdict: approved > [!NOTE] > Written by Claude Opus 5.5 in Claude Code and reviewed by GPT 6.1 Sol and Claude Opus 5.5 (via T3 Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
1 parent 5380816 commit dd46679

6 files changed

Lines changed: 64 additions & 28 deletions

File tree

‎crates/ui/assets/style/narrow.css‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,6 @@
114114
.status {
115115
padding-inline: 1rem;
116116
}
117-
.topbar .search {
118-
width: auto;
119-
flex: 1 1 6rem;
120-
max-width: 50%;
121-
}
122117
.crumb {
123118
flex: 1 1 auto;
124119
}
@@ -141,7 +136,6 @@
141136
.topbar .search {
142137
order: 10;
143138
flex: 1 1 100%;
144-
max-width: none;
145139
}
146140
}
147141
@media (max-width: 520px) {

‎crates/ui/assets/style/shell.css‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ body.admin .main::before {
330330
border-color: var(--focus);
331331
}
332332
.search-box input {
333+
/* Shrinks with the form, so the box never runs under the avatar beside it. */
334+
min-width: 0;
333335
min-height: 30px;
334336
padding: 0.2rem 0;
335337
border: 0;

‎tests/browser/README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ reason, and start a recovery whose link is mailed, then undo it. Support also
126126
renames a handle, which an owner may change only 30 days after signup: the new
127127
one signs in at once, and the old one no longer does. Another reads an account's
128128
security history, rotates a signing key and revokes it again, filters the
129-
delivery queue, and reserves a handle and removes the reservation again. Set
129+
delivery queue, and reserves a handle and removes the reservation again. The
130+
top bar keeps its crumb, search box and avatar apart at every window size. Set
130131
`E2E_ADMIN_URL` to the dashboard's origin and `E2E_GRANT_ADMIN` to a command
131132
that grants administrator rights to the handle appended to it, e.g. `just auth
132133
admin grant` with the deployment's configuration. Without them, the tests are

‎tests/browser/admin.spec.ts‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import {
88
consent,
99
mailed,
1010
mailUrl,
11+
scrollsSideways,
1112
serveClient,
1213
signedUp,
1314
signUp,
15+
viewports,
1416
withPasskeys
1517
} from './helpers';
1618

@@ -71,6 +73,43 @@ function entry(page: Page, change: string, reason: string) {
7173
.first();
7274
}
7375

76+
/**
77+
* The top bar at every size: the crumb, the search box and the avatar each keep
78+
* their own room. The search box has run under the avatar on tablets before, as
79+
* its input refused to shrink with the form.
80+
*/
81+
test("the dashboard's top bar fits every window size", async ({ browser }) => {
82+
const admin = await administrator(browser, `bar-${Date.now().toString(36)}`);
83+
await admin.goto(`${adminUrl}/users`);
84+
const bar = admin.locator('.topbar');
85+
const parts = {
86+
crumb: bar.locator('.crumb'),
87+
search: bar.locator('.search-box'),
88+
avatar: bar.getByRole('link', { name: 'Your account', exact: true })
89+
};
90+
for (const viewport of viewports) {
91+
await admin.setViewportSize(viewport);
92+
expect(await scrollsSideways(admin), viewport.name).toBe(false);
93+
const boxes = await Promise.all(
94+
Object.entries(parts).map(async ([name, part]) => {
95+
const box = await part.boundingBox();
96+
if (!box) throw new Error(`${viewport.name}: the ${name} is not shown`);
97+
return { name, ...box };
98+
})
99+
);
100+
for (const [i, a] of boxes.entries()) {
101+
for (const b of boxes.slice(i + 1)) {
102+
const crosses =
103+
a.x < b.x + b.width &&
104+
b.x < a.x + a.width &&
105+
a.y < b.y + b.height &&
106+
b.y < a.y + a.height;
107+
expect(crosses, `${viewport.name}: ${a.name} crosses ${b.name}`).toBe(false);
108+
}
109+
}
110+
}
111+
});
112+
74113
test('an administrator disables a user from the dashboard, and the user is signed out', async ({
75114
browser
76115
}) => {

‎tests/browser/helpers.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,25 @@ import {
1212
/** Auth's origin, which the suite's `baseURL` also names. */
1313
export const authUrl = process.env.E2E_AUTH_URL ?? 'http://localhost:3000';
1414

15+
/**
16+
* The window sizes the pages must work at, the smallest phone to a wide desktop,
17+
* either side of the drawer's breakpoint. Few, and few pages each: auth's pages
18+
* share one request budget a minute, which the whole suite spends.
19+
*/
20+
export const viewports = [
21+
{ name: 'small phone', width: 320, height: 568 },
22+
{ name: 'tablet', width: 768, height: 1024 },
23+
{ name: 'laptop', width: 1280, height: 800 },
24+
{ name: 'desktop', width: 1920, height: 1080 }
25+
];
26+
27+
/** Whether the page body scrolls sideways, which no page may. */
28+
export async function scrollsSideways(page: Page): Promise<boolean> {
29+
return page.evaluate(
30+
() => document.documentElement.scrollWidth > document.documentElement.clientWidth
31+
);
32+
}
33+
1534
/**
1635
* A virtual platform authenticator on `page`, which verifies its user without
1736
* asking. A `synced` one backs its credentials up, like a synced passkey.

‎tests/browser/layout.spec.ts‎

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,5 @@
1-
import { expect, test, type Page } from '@playwright/test';
2-
import { signUp, withPasskeys } from './helpers';
3-
4-
/**
5-
* The window sizes the pages must work at, the smallest phone to a wide desktop,
6-
* either side of the drawer's breakpoint. Few, and few pages each: auth's pages
7-
* share one request budget a minute, which the whole suite spends.
8-
*/
9-
const viewports = [
10-
{ name: 'small phone', width: 320, height: 568 },
11-
{ name: 'tablet', width: 768, height: 1024 },
12-
{ name: 'laptop', width: 1280, height: 800 },
13-
{ name: 'desktop', width: 1920, height: 1080 }
14-
];
15-
16-
/** Whether the page body scrolls sideways, which no page may. */
17-
async function scrollsSideways(page: Page): Promise<boolean> {
18-
return page.evaluate(
19-
() => document.documentElement.scrollWidth > document.documentElement.clientWidth
20-
);
21-
}
1+
import { expect, test } from '@playwright/test';
2+
import { scrollsSideways, signUp, viewports, withPasskeys } from './helpers';
223

234
/**
245
* The shell at every size: the sidebar beside the page on wide windows, a drawer

0 commit comments

Comments
 (0)