Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(views): stop doc and project mention links from outgrowing their chip (MUL-9859) (#11196)

Jiayuan Zhangced54c2b6023
diff --git a/e2e/docs.spec.ts b/e2e/docs.spec.ts
index 1ac24c14dd..7c6f96871e 100644
--- a/e2e/docs.spec.ts
+++ b/e2e/docs.spec.ts
@@ -369,6 +369,43 @@ test("docs link from issues, show up in Cmd+K, and reorganize from the tree", as
await page.screenshot({ path: info.outputPath("docs-tree.png"), animations: "disabled", style: "nextjs-portal { display: none; }" });
});
+test("a doc or project mention's link is no wider than its truncated chip", async ({ page }) => {
+ // A flex link around the chip drops the chip's min(18rem, 100%) cap while
+ // sizing itself, so a long title leaves a blank gap after the truncated
+ // chip and pushes the following text away (MUL-9859).
+ const doc = await api.createDoc(
+ "GEO baseline report: share of voice across buyer prompts and competitor citations",
+ "Baseline.",
+ );
+ const project = await api.createProject(
+ "GEO observability: daily buyer prompt tracking and citation share dashboard",
+ );
+ const body = [
+ "1. Fix existing pages first",
+ ` - The [baseline](mention://doc/${doc.id}) confirms it, and [the project](mention://project/${project.id}) tracks it.`,
+ "",
+ `In a paragraph: [baseline](mention://doc/${doc.id}) and [the project](mention://project/${project.id}).`,
+ ].join("\n");
+ const issue = await api.createIssue("Mention chips in a list", { description: body });
+ await api.createComment(issue.id, body);
+
+ // The description renders through the editor, the comment through the
+ // readonly renderer: two of each chip on both.
+ await page.goto(`/${slug}/issues/${issue.id}`);
+ await expect(page.locator(".doc-chip").filter({ hasText: "GEO baseline report" })).toHaveCount(4);
+ await expect(page.locator(".project-chip").filter({ hasText: "GEO observability" })).toHaveCount(4);
+
+ const gaps = await page.locator("a.doc-mention, a.project-mention").evaluateAll((links) =>
+ links.map((link) => {
+ const chip = link.querySelector(".doc-chip, .project-chip")!;
+ const { marginLeft, marginRight } = getComputedStyle(chip);
+ const hug = chip.getBoundingClientRect().width + parseFloat(marginLeft) + parseFloat(marginRight);
+ return Math.round(Math.abs(link.getBoundingClientRect().width - hug));
+ }),
+ );
+ expect(gaps).toEqual(Array(8).fill(0));
+});
+
test("Cmd+K finds a doc by words that only appear in its content", async ({ page }) => {
const doc = await api.createDoc(
"Release runbook",
diff --git a/packages/views/docs/components/doc-mention-card.tsx b/packages/views/docs/components/doc-mention-card.tsx
index a1fe5e4ffe..414641abbb 100644
--- a/packages/views/docs/components/doc-mention-card.tsx
+++ b/packages/views/docs/components/doc-mention-card.tsx
@@ -36,11 +36,14 @@ export function DocMentionCard({
const title = doc
? doc.title || t(($) => $.untitled)
: fallbackLabel || t(($) => $.untitled);
+ // The link stays a plain inline box, as in IssueMentionCard: a flex wrapper
+ // drops the chip's percentage cap while sizing itself, so the link grows to
+ // the untruncated title and leaves a blank gap after the chip.
return (
<AppLink
href={p.docDetail(docId)}
newTabTitle={title}
- className="doc-mention inline-flex max-w-full"
+ className="doc-mention align-middle"
>
<span className="doc-chip mx-0.5 inline-flex min-w-0 max-w-[min(18rem,100%)] items-center gap-1.5 rounded-md border px-2 py-0.5 text-caption">
<FileText className="size-3.5 shrink-0 text-muted-foreground" />
diff --git a/packages/views/projects/components/project-mention-card.tsx b/packages/views/projects/components/project-mention-card.tsx
index d3865182cb..9f46423a1c 100644
--- a/packages/views/projects/components/project-mention-card.tsx
+++ b/packages/views/projects/components/project-mention-card.tsx
@@ -63,7 +63,7 @@ export function ProjectMentionCard({
<AppLink
href={p.projectDetail(projectId)}
newTabTitle={fallbackLabel}
- className="project-mention inline-flex"
+ className="project-mention align-middle"
onContextMenu={
project
? (event) => {