Skip to content

Commit 4ecdf01

Browse files
bostonaholicclaude
andauthored
fix(links): render one hash on completed channel links (#506)
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
1 parent baeb2c8 commit 4ecdf01

3 files changed

Lines changed: 17 additions & 8 deletions

File tree

‎src/bundled/channels/ChannelCompletion.test.tsx‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ it("distinguishes loading, empty and failed lists; only explicit retry refreshes
221221
});
222222

223223
it.each([true, false])(
224-
"renders the authored label and stable target with member visibility %s",
224+
"renders the channel name without its hash beside the icon, with the stable target and member visibility %s",
225225
(member) => {
226226
const name = "crew-ops [a] & <b>";
227227
const row = channel("stable", { name, private: true });
@@ -268,8 +268,9 @@ it.each([true, false])(
268268
onOpenLink={onOpenLink}
269269
/>,
270270
);
271-
const link = screen.getByRole("link", { name: `#${name}` });
272-
expect(link.textContent).toBe(`#${name}`);
271+
const link = screen.getByRole("link", { name: "#crew-ops [a] & <b>" });
272+
expect(link.querySelector('svg[aria-hidden="true"]')).not.toBeNull();
273+
expect(link.textContent).toBe("crew-ops [a] & <b>");
273274
expect(link.getAttribute("href")).toBe("buzz://channel/stable");
274275
expect(screen.getAllByRole("link")).toHaveLength(1);
275276
fireEvent.click(link);

‎src/bundled/links/InlineLink.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ export function LinkLabel({
140140
}
141141
// The channel icon already supplies the visual hash.
142142
if (kind === "channel" && label.startsWith("#")) label = label.slice(1);
143+
const visibleContent =
144+
kind === "channel" && typeof content === "string" && content.startsWith("#")
145+
? content.slice(1)
146+
: content;
143147
// Markdown encodes Unicode in destinations while retaining it in visible text.
144148
const rawDestination =
145149
label === href ||
@@ -149,7 +153,7 @@ export function LinkLabel({
149153
return (
150154
<span data-link-kind={kind}>
151155
<Icon aria-hidden="true" className={styles.icon} />
152-
{content}
156+
{visibleContent}
153157
</span>
154158
);
155159
// Shorten only raw destinations; authored labels and resolved channel names stay intact.

‎tests/browser/channel-completion.spec.mjs‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ test("channel completion preserves native editing, focus, popup geometry and sig
8181
"value",
8282
"[\\#General](buzz://channel/c) ",
8383
);
84-
await expect(input.locator("[data-link-renderer]")).toHaveText("#General");
84+
await expect(input.locator("[data-link-renderer]")).toHaveText("General");
85+
await expect(
86+
input.locator('[data-link-renderer] svg[aria-hidden="true"]'),
87+
).toHaveCount(1);
8588
await expect(input).toBeFocused();
8689
expect(
8790
await page.evaluate(() => window.mentionFixture.publications),
@@ -137,9 +140,10 @@ test("channel completion preserves native editing, focus, popup geometry and sig
137140
"value",
138141
"[\\#General](buzz://channel/c) ",
139142
);
140-
await expect(input.locator("[data-link-renderer]")).toHaveText(
141-
"#General",
142-
);
143+
await expect(input.locator("[data-link-renderer]")).toHaveText("General");
144+
await expect(
145+
input.locator('[data-link-renderer] svg[aria-hidden="true"]'),
146+
).toHaveCount(1);
143147
await input.press(shortcut);
144148
await input.press("ControlOrMeta+a");
145149
await input.press("Backspace");

0 commit comments

Comments
 (0)