Skip to content

Commit 7ae9be9

Browse files
matt2eclaude
andcommitted
fix(messages): resolve "N others" names only while the list is open
The "N others" list built every member's profile button whenever its membership row rendered, even with the list closed: an npub encode plus the host's canOpenLink per member, about 3.75 ms per pass for a 602-member burst and repeated on each memo miss while the burst's profiles load. The list moves into a MembershipPeople component inside PopoverPopup, whose portal mounts it only while the list is open. The list's scrollport clipped its entries: each .link overhangs by space-half, so the hover fill lost 2px on the left and the 2px-offset keyboard ring was cut on the left of every entry and the top of the first. Following DESIGN.md "Focus recipes", the scrollport gains space-half of inline padding (offset by a matching negative margin, so names stay aligned with the title) and the entries' ring is inset with outline-offset: -2px. Member names now rest at currentColor instead of text-subtle. Row names still inherit the caption's text-subtle, while listed names take the popover's text-standard rather than reading dimmer than the plain entries around them. Hover and keyboard focus keep the inline-reference colour. The comment no longer says medium weight is the only resting cue; the .link underline stays. Tests: the "N others" RTL case asserts that a closed list asks the host about its lead name only, which fails against the inline map. The join-burst journey checks that a resting entry matches the list's colour, Tabs to the first name, asserts its drawn ring fits inside the scrollport and saves a focus screenshot. The colour and clip assertions fail before their fixes (rgb(82, 82, 82) vs rgb(15, 15, 15); 6px clipped). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Matt Toohey <[email protected]>
1 parent 764e4c2 commit 7ae9be9

4 files changed

Lines changed: 72 additions & 16 deletions

File tree

‎src/features/messages/MembershipRow.tsx‎

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,22 +93,38 @@ function MembershipPreview({
9393
// biome-ignore lint/a11y/noNoninteractiveTabindex: The bounded member list needs keyboard focus for native scrolling.
9494
tabIndex={0}
9595
>
96-
<ul>
97-
{members.map((member) => {
98-
const name = profileName(links, member.id, member.name, trigger);
99-
return (
100-
<li key={member.id}>
101-
{name ? <PopoverClose render={name} /> : member.name}
102-
</li>
103-
);
104-
})}
105-
</ul>
96+
<MembershipPeople members={members} links={links} trigger={trigger} />
10697
</section>
10798
</PopoverPopup>
10899
</PopoverRoot>
109100
);
110101
}
111102

103+
/** The listed names. The portal mounts this only while the list is open, so a
104+
* large burst resolves each member's profile target only when someone looks. */
105+
function MembershipPeople({
106+
members,
107+
links,
108+
trigger,
109+
}: {
110+
members: readonly { id: string; name: string }[];
111+
links: ProfileLinks;
112+
trigger: RefObject<HTMLButtonElement | null>;
113+
}) {
114+
return (
115+
<ul>
116+
{members.map((member) => {
117+
const name = profileName(links, member.id, member.name, trigger);
118+
return (
119+
<li key={member.id}>
120+
{name ? <PopoverClose render={name} /> : member.name}
121+
</li>
122+
);
123+
})}
124+
</ul>
125+
);
126+
}
127+
112128
/** Quiet, non-conversational activity. Avatars are decorative; prose owns the
113129
* label, and each named member opens their profile like a prose mention. */
114130
export const MembershipRow = memo(function MembershipRow({

‎src/features/messages/Messages.module.css‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,12 +1852,13 @@ html[data-keyboard-navigation] .text pre code:focus-visible {
18521852
min-width: 0;
18531853
overflow-wrap: anywhere;
18541854
}
1855-
/* A quiet log line: member names keep the caption color at rest, carry
1856-
medium weight as their only resting cue, and take the inline-reference
1857-
color while hovered or keyboard-focused. The shared chip fill and ring stay.
1858-
The "N others" list renders in a portal, outside the row, so it is named too. */
1855+
/* A quiet log line: member names rest in their surrounding text color (the
1856+
row's caption, the list's body), keep the link underline, add medium weight,
1857+
and take the inline-reference color while hovered or keyboard-focused. The
1858+
shared chip fill and ring stay. The "N others" list renders in a portal,
1859+
outside the row, so it is named too. */
18591860
:is(.membership, .membershipPeople) .membershipName {
1860-
--link-text: var(--text-subtle);
1861+
--link-text: currentColor;
18611862
/* Restated over the channel host's button reset. */
18621863
color: var(--link-text);
18631864
font-weight: var(--type-weight-medium);
@@ -1873,8 +1874,15 @@ html[data-keyboard-navigation]
18731874
overflow-y: auto;
18741875
overscroll-behavior: contain;
18751876
margin-top: var(--space-2);
1877+
/* Inline room in the scrollport for each name's hover overhang. */
1878+
padding-inline: var(--space-half);
1879+
margin-inline: calc(-1 * var(--space-half));
18761880
@apply text-body-sm text-standard;
18771881
}
1882+
/* The scrollport would clip an offset ring, so the names' ring is inset. */
1883+
html[data-keyboard-navigation] .membershipPeople .membershipName:focus-visible {
1884+
outline-offset: -2px;
1885+
}
18781886
.membershipPeople ul {
18791887
list-style: none;
18801888
margin: 0;

‎src/features/messages/membership-rows.test.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,9 @@ it("listed members open profiles and return focus to the overflow control", asyn
396396
origins.push(document.activeElement);
397397
return true;
398398
});
399+
const canOpenLink = vi.fn(
400+
(target: string) => target !== profileTarget(unnamed),
401+
);
399402
render(
400403
<MembershipRow
401404
row={group}
@@ -405,9 +408,11 @@ it("listed members open profiles and return focus to the overflow control", asyn
405408
viewer={wes}
406409
day={false}
407410
onOpenLink={open}
408-
canOpenLink={(target) => target !== profileTarget(unnamed)}
411+
canOpenLink={canOpenLink}
409412
/>,
410413
);
414+
// A closed list asks the host about its lead name only, not every member.
415+
expect(canOpenLink.mock.calls).toEqual([[profileTarget(pinky)]]);
411416
const user = userEvent.setup();
412417
const others = screen.getByRole("button", { name: "3 others" });
413418
const list = async () => {

‎tests/browser/membership.spec.mjs‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,33 @@ burstTest(
361361
await others.press("Enter");
362362
await expect(popup).toBeVisible();
363363
await expect(people).toBeFocused();
364+
// Names rest in the list's own color; Tab reaches the first one, whose
365+
// ring and fill fit inside the scrollport instead of being clipped.
366+
const first = people.getByRole("button").first();
367+
await expect(first).toHaveCSS(
368+
"color",
369+
await people.evaluate((list) => getComputedStyle(list).color),
370+
);
371+
await page.keyboard.press("Tab");
372+
await expect(first).toBeFocused();
373+
await expect(first).toHaveCSS("outline-style", "solid");
374+
const clipped = await first.evaluate((entry) => {
375+
const list = entry.closest("section");
376+
const port = list.getBoundingClientRect();
377+
const box = entry.getBoundingClientRect();
378+
const style = getComputedStyle(entry);
379+
const ring =
380+
parseFloat(style.outlineOffset) + parseFloat(style.outlineWidth);
381+
return Math.max(
382+
port.left - (box.left - ring),
383+
port.top - (box.top - ring),
384+
box.right + ring - (port.left + list.clientWidth),
385+
);
386+
});
387+
expect(clipped).toBeLessThanOrEqual(0);
388+
await popup.screenshot({
389+
path: testInfo.outputPath("membership-people-focus.png"),
390+
});
364391
await people.press("End");
365392
await expect(people.getByRole("listitem").last()).toBeInViewport();
366393
await page.keyboard.press("Escape");

0 commit comments

Comments
 (0)