Skip to content

Commit 7981597

Browse files
tellahonpub1223z34hd7vtwc6qj4s7flsxkj644nlre2nthu7lrrmkumhu3xddsrx9r6w
andauthored
fix(reactions): wrap long popover names (block#3834)
**Category:** fix **User Impact:** Long custom emoji names now stay contained inside reaction popovers and remain fully readable. **Problem:** An unbroken custom emoji name could force a reaction popover beyond its intended maximum width and overflow the message view. **Solution:** Give the reaction popover a definite 288px width and allow the complete emoji name to wrap within it without truncation or ellipsis. Short names retain the same content and interaction behavior. <details> <summary>File changes</summary> **desktop/src/features/messages/ui/MessageReactions.tsx** Bounds the reaction popover width and allows long names to break across lines while preserving the full shortcode. **desktop/tests/e2e/reaction-names.spec.ts** Covers fixed width, full text preservation, and wrapping for the maximum supported colon-wrapped reaction name, with deterministic seeded Picsum visual fixtures and explicit image-load waits. </details> ## Reproduction Steps 1. Open a message with a custom emoji reaction whose name is 64 characters. 2. Hover or focus the reaction pill to open its details popover. 3. Confirm the popover remains 288px wide and the complete name wraps within it without ellipsis. 4. Open a short-name reaction and confirm its popover remains readable and unchanged in behavior. ## Screenshots | Before | After | | --- | --- | | ![Maximum-length name before](https://d24qwcpro867f5.cloudfront.net/repos/buzz/prs/3834/max-length-before-picsum.png) | ![Maximum-length name after](https://d24qwcpro867f5.cloudfront.net/repos/buzz/prs/3834/max-length-after-picsum.png) | **Short-name regression check** ![Short reaction name](https://d24qwcpro867f5.cloudfront.net/repos/buzz/prs/3834/short-name-after-picsum.png) ## Verification - `pnpm test` in `desktop`: 3,858 passed - Focused reaction-name E2E with seeded Picsum captures: 2 passed - Desktop checks and commit hooks passed Originating Buzz channel: `f2ec9671-d78e-4cde-894c-9f4c458c7f1f` --------- Signed-off-by: Taylor Ho <[email protected]> Co-authored-by: npub1223z34hd7vtwc6qj4s7flsxkj644nlre2nthu7lrrmkumhu3xddsrx9r6w <52a228d6edf316ec6812ac3c9fc0d696ab59fc7954d77e7be31eedcddf91335b@buzz.block.builderlab.xyz>
1 parent d4a4570 commit 7981597

2 files changed

Lines changed: 128 additions & 8 deletions

File tree

‎desktop/src/features/messages/ui/MessageReactions.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ function ReactionPopoverContent({ reaction }: { reaction: TimelineReaction }) {
126126
<div className="max-w-[14rem] text-balance text-sm font-semibold leading-snug text-popover-foreground">
127127
{userText} <span className="text-muted-foreground">reacted with</span>
128128
</div>
129-
<div className="mt-0.5 text-sm font-semibold leading-snug text-muted-foreground">
129+
<div
130+
className="mt-0.5 break-all text-sm font-semibold leading-snug text-muted-foreground"
131+
data-testid="reaction-popover-name"
132+
>
130133
{displayName}
131134
</div>
132135
</div>
@@ -504,7 +507,7 @@ function ReactionPill({
504507
align="start"
505508
side="top"
506509
sideOffset={6}
507-
className="w-auto min-w-56 max-w-72 rounded-xl p-3"
510+
className="w-72 rounded-xl p-3"
508511
onMouseEnter={handleMouseEnter}
509512
onMouseLeave={scheduleClose}
510513
onOpenAutoFocus={(e) => e.preventDefault()}

‎desktop/tests/e2e/reaction-names.spec.ts‎

Lines changed: 123 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
import { expect, test } from "@playwright/test";
2+
import * as fs from "node:fs";
3+
import * as path from "node:path";
24

5+
import { waitForAnimations } from "../helpers/animations";
36
import { installMockBridge } from "../helpers/bridge";
47

58
const REACTION_TARGET_CONTENT = "React to me with a custom emoji";
69
const REACTION_TARGET_EVENT_ID = "d".repeat(64);
710
const BOB_PUBKEY =
811
"bb22a5299220cad76ffd46190ccbeede8ab5dc260faa28b6e5a2cb31b9aff260";
12+
const MAX_REACTION_NAME =
13+
"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl";
14+
const MAX_REACTION_AVATAR_URL =
15+
'data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"%3E%3Crect width="16" height="16" rx="4" fill="%23e5484d"/%3E%3C/svg%3E';
16+
const SHORT_REACTION_AVATAR_URL =
17+
'data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"%3E%3Crect width="16" height="16" rx="4" fill="%2300a36c"/%3E%3C/svg%3E';
18+
const SCREENSHOT_DIR =
19+
process.env.REACTION_POPOVER_SCREENSHOT_DIR ??
20+
"test-results/reaction-popover-screenshots";
921

1022
function reactionTargetRow(page: import("@playwright/test").Page) {
1123
return page
@@ -14,8 +26,45 @@ function reactionTargetRow(page: import("@playwright/test").Page) {
1426
.last();
1527
}
1628

29+
async function waitForImage(
30+
image: import("@playwright/test").Locator,
31+
): Promise<void> {
32+
await expect(image).toBeVisible();
33+
await expect
34+
.poll(() =>
35+
image.evaluate(
36+
(element) =>
37+
element instanceof HTMLImageElement &&
38+
element.complete &&
39+
element.naturalWidth > 0,
40+
),
41+
)
42+
.toBe(true);
43+
}
44+
45+
async function capturePopover(
46+
page: import("@playwright/test").Page,
47+
popover: import("@playwright/test").Locator,
48+
filename: string,
49+
): Promise<void> {
50+
fs.mkdirSync(SCREENSHOT_DIR, { recursive: true });
51+
await waitForAnimations(page);
52+
await popover.screenshot({
53+
animations: "disabled",
54+
path: path.join(SCREENSHOT_DIR, filename),
55+
});
56+
}
57+
1758
test.beforeEach(async ({ page }) => {
18-
await installMockBridge(page);
59+
await installMockBridge(page, {
60+
searchProfiles: [
61+
{
62+
pubkey: BOB_PUBKEY,
63+
displayName: "bob",
64+
avatarUrl: SHORT_REACTION_AVATAR_URL,
65+
},
66+
],
67+
});
1968
});
2069

2170
test("reaction popover resolves a reactor with no authored message in the window", async ({
@@ -33,21 +82,89 @@ test("reaction popover resolves a reactor with no authored message in the window
3382
);
3483

3584
await page.evaluate(
36-
({ pubkey, targetId }) => {
85+
({ pubkey, targetId, avatarUrl }) => {
3786
window.__BUZZ_E2E_EMIT_MOCK_MESSAGE__?.({
3887
channelName: "general",
39-
content: "🎉",
40-
extraTags: [["e", targetId]],
88+
content: ":react:",
89+
extraTags: [
90+
["e", targetId],
91+
["emoji", "react", avatarUrl],
92+
],
4193
kind: 7,
4294
pubkey,
4395
});
4496
},
45-
{ pubkey: BOB_PUBKEY, targetId: REACTION_TARGET_EVENT_ID },
97+
{
98+
avatarUrl: SHORT_REACTION_AVATAR_URL,
99+
pubkey: BOB_PUBKEY,
100+
targetId: REACTION_TARGET_EVENT_ID,
101+
},
46102
);
47103

48104
const row = reactionTargetRow(page);
49-
const pill = row.getByRole("button", { name: "Toggle 🎉 reaction" });
105+
const pill = row.getByRole("button", { name: "Toggle :react: reaction" });
50106
await expect(pill).toBeVisible();
51107
await pill.hover();
52108
await expect(page.getByText("bob reacted with")).toBeVisible();
109+
const popover = page
110+
.locator("[data-radix-popper-content-wrapper]")
111+
.filter({ hasText: "bob reacted with" });
112+
const avatar = popover.locator("img");
113+
await expect(avatar).toHaveAttribute("src", SHORT_REACTION_AVATAR_URL);
114+
await waitForImage(avatar);
115+
await capturePopover(page, popover, "short-name-after.png");
116+
});
117+
118+
test("maximum-length reaction name wraps inside a fixed-width popover", async ({
119+
page,
120+
}) => {
121+
await page.goto("/");
122+
await page.getByTestId("channel-general").click();
123+
await expect(page.getByTestId("chat-title")).toHaveText("general");
124+
await page.waitForFunction(
125+
() =>
126+
window.__BUZZ_E2E_HAS_MOCK_LIVE_SUBSCRIPTION__?.({
127+
channelName: "general",
128+
kind: 7,
129+
}) === true,
130+
);
131+
132+
const reaction = `:${MAX_REACTION_NAME}:`;
133+
await page.evaluate(
134+
({ content, targetId, avatarUrl }) => {
135+
window.__BUZZ_E2E_EMIT_MOCK_MESSAGE__?.({
136+
channelName: "general",
137+
content,
138+
extraTags: [
139+
["e", targetId],
140+
["emoji", content.slice(1, -1), avatarUrl],
141+
],
142+
kind: 7,
143+
});
144+
},
145+
{
146+
avatarUrl: MAX_REACTION_AVATAR_URL,
147+
content: reaction,
148+
targetId: REACTION_TARGET_EVENT_ID,
149+
},
150+
);
151+
152+
const pill = reactionTargetRow(page).getByRole("button", {
153+
name: `Toggle ${reaction} reaction`,
154+
});
155+
await expect(pill).toBeVisible();
156+
await pill.focus();
157+
158+
const popover = page
159+
.locator("[data-radix-popper-content-wrapper]")
160+
.filter({ hasText: reaction });
161+
await expect(popover).toBeVisible();
162+
await expect(popover).toHaveCSS("width", "288px");
163+
const reactionName = popover.getByTestId("reaction-popover-name");
164+
await expect(reactionName).toHaveCSS("word-break", "break-all");
165+
await expect(reactionName).toHaveText(reaction);
166+
const avatar = popover.locator("img");
167+
await expect(avatar).toHaveAttribute("src", MAX_REACTION_AVATAR_URL);
168+
await waitForImage(avatar);
169+
await capturePopover(page, popover, "max-length-after.png");
53170
});

0 commit comments

Comments
 (0)