Skip to content

Commit b6dc533

Browse files
tellahoCarl
andauthored
fix(composer): align wrapped inline chip fragments (#7242)
**Category:** fix **User Impact:** Wrapped channel and mention chips in the chat composer now align continuation text with the chip edge while keeping the icon on the first line. **Problem:** Plain composer decorations used absolute icons plus cloned icon-sized padding, so every wrapped fragment inherited an empty icon gap and the icon aligned against the union of all lines. **Solution:** Keep the icon in the first fragment's inline flow and restore normal chip padding on continuation fragments, while explicitly leaving the separate wrapping Buzz-link and sent-message rendering paths unchanged. <details> <summary>File changes</summary> **desktop/src/shared/styles/globals/composer.css** Scopes in-flow icon geometry and normal continuation padding to plain composer mention and channel decorations, excluding wrapping atom-link chips and preserving the human-icon vertical correction. **desktop/tests/e2e/mentions.spec.ts** Adds a rendered narrow-composer regression that checks two fragments, static icon geometry, first-line icon space, and continuation-line alignment to ordinary chip padding. </details> ## Reproduction steps 1. Open a channel in Buzz Desktop. 2. Narrow the chat composer enough for `#all-replies` to wrap. 3. Confirm the channel icon occupies only the first line and `replies` starts at the chip's normal left padding rather than an icon-sized inset. 4. Send or view a long inline Buzz chip in the message list at a constrained width. 5. Confirm its icon remains attached to the leading fragment and its remaining label continues cleanly on following lines. ## Screenshots **Composer — wrapped `#all-replies` channel reference** ![Wrapped channel reference in the narrow dark-theme composer](https://d24qwcpro867f5.cloudfront.net/repos/buzz/prs/7242/composer-wrapped-channel.png) **Message list — existing wrapped inline-chip rendering preserved** ![Wrapped repository chip in a sent message at constrained width](https://d24qwcpro867f5.cloudfront.net/repos/buzz/prs/7242/message-list-wrapped-chip.png) Signed-off-by: Taylor Ho <[email protected]> Co-authored-by: Carl <acda9e433d19dcd0e6b6840f7f4b98f3a56f1fab98049d444c087019e6d36560@buzz.block.builderlab.xyz>
1 parent 91ab9d3 commit b6dc533

2 files changed

Lines changed: 104 additions & 4 deletions

File tree

‎desktop/src/shared/styles/globals/composer.css‎

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,10 @@
259259
260260
Plain-text mention decorations stay inline because inline-flex pulls the
261261
caret into their decorated range and swallows the trailing space after an
262-
@mention. Composer Buzz links are atom nodes, but their labels may still
263-
fragment between characters; only the icon and leading label fragment stay
264-
together. The line-height keeps each inline decoration box tall enough to
265-
paint both block-padding edges without clipping. */
262+
@mention. Their generated icon participates in the first line's inline
263+
flow: absolute positioning anchors it to the union of every wrapped line,
264+
and icon-sized left padding is cloned onto every continuation fragment.
265+
Composer Buzz links are atom nodes with their own leading-fragment wrapper. */
266266
.rich-text-composer .tiptap .mention-chip {
267267
display: inline;
268268
min-height: 0;
@@ -272,3 +272,25 @@
272272
var(--inline-chip-padding-block-end)
273273
);
274274
}
275+
276+
.rich-text-composer
277+
.tiptap
278+
.mention-chip.inline-chip-with-icon:not(.wrapping-inline-chip) {
279+
padding-left: var(--inline-chip-padding-inline);
280+
}
281+
282+
.rich-text-composer
283+
.tiptap
284+
.mention-chip.inline-chip-with-icon:not(.wrapping-inline-chip)::before {
285+
position: static;
286+
display: inline-block;
287+
margin-right: var(--inline-chip-icon-gap);
288+
transform: none;
289+
vertical-align: -0.125em;
290+
}
291+
292+
.rich-text-composer
293+
.tiptap
294+
.mention-chip.inline-chip-icon-human:not(.wrapping-inline-chip)::before {
295+
transform: translateY(0.0625rem);
296+
}

‎desktop/tests/e2e/mentions.spec.ts‎

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,84 @@ test("typing an unregistered @token before existing text is left alone", async (
11901190
await expect(input).toHaveText("hello @zzq world");
11911191
});
11921192

1193+
test("wrapped channel references keep the icon on the first composer line", async ({
1194+
page,
1195+
}) => {
1196+
await page.goto("/");
1197+
await page.getByTestId("channel-general").click();
1198+
await expect(page.getByTestId("chat-title")).toHaveText("general");
1199+
1200+
const input = page.getByTestId("message-input");
1201+
await page.getByTestId("message-input-scroll").evaluate((element) => {
1202+
element.style.width = "74px";
1203+
});
1204+
await input.fill("#all-replies");
1205+
1206+
const channelChip = input.locator(".inline-chip-icon-channel", {
1207+
hasText: "all-replies",
1208+
});
1209+
await expect(channelChip).toBeVisible();
1210+
// CSSOM exposes pseudo-element styles but not their rendered box.
1211+
const cdp = await page.context().newCDPSession(page);
1212+
const { root } = await cdp.send("DOM.getDocument", {
1213+
depth: -1,
1214+
pierce: true,
1215+
});
1216+
const { nodeId } = await cdp.send("DOM.querySelector", {
1217+
nodeId: root.nodeId,
1218+
selector: ".rich-text-composer .inline-chip-icon-channel",
1219+
});
1220+
const { node } = await cdp.send("DOM.describeNode", { nodeId, depth: 1 });
1221+
const before = node.pseudoElements?.find(
1222+
(pseudo) => pseudo.pseudoType === "before",
1223+
);
1224+
if (!before) {
1225+
throw new Error("Channel chip is missing its generated icon");
1226+
}
1227+
const iconBox = await cdp.send("DOM.getBoxModel", { nodeId: before.nodeId });
1228+
const iconTop = iconBox.model.border[1];
1229+
await cdp.detach();
1230+
const geometry = await channelChip.evaluate((element) => {
1231+
const textNode = element.firstChild;
1232+
if (!(textNode instanceof Text)) {
1233+
throw new Error("Channel chip is missing its decorated text node");
1234+
}
1235+
const textRange = document.createRange();
1236+
textRange.selectNodeContents(textNode);
1237+
const rects = (source: DOMRectList) =>
1238+
Array.from(source, (rect) => ({
1239+
left: rect.left,
1240+
top: rect.top,
1241+
}));
1242+
const iconStyle = getComputedStyle(element, "::before");
1243+
const tokenProbe = document.createElement("span");
1244+
tokenProbe.style.cssText =
1245+
"position:fixed;width:var(--inline-chip-padding-inline)";
1246+
element.append(tokenProbe);
1247+
const tokenPadding = tokenProbe.getBoundingClientRect().width;
1248+
tokenProbe.remove();
1249+
return {
1250+
chipRects: rects(element.getClientRects()),
1251+
iconPosition: iconStyle.position,
1252+
iconTransform: iconStyle.transform,
1253+
tokenPadding,
1254+
textRects: rects(textRange.getClientRects()),
1255+
};
1256+
});
1257+
expect(geometry.chipRects).toHaveLength(2);
1258+
expect(geometry.textRects).toHaveLength(2);
1259+
expect(geometry.iconPosition).toBe("static");
1260+
expect(geometry.iconTransform).toBe("none");
1261+
expect(
1262+
geometry.textRects[0].left - geometry.chipRects[0].left,
1263+
).toBeGreaterThan(geometry.tokenPadding);
1264+
expect(geometry.textRects[1].left - geometry.chipRects[1].left).toBeCloseTo(
1265+
geometry.tokenPadding,
1266+
0,
1267+
);
1268+
expect(iconTop - geometry.textRects[0].top).toBeCloseTo(2.5, 0);
1269+
});
1270+
11931271
test("channel references keep caret movement through the channel name", async ({
11941272
page,
11951273
}) => {

0 commit comments

Comments
 (0)