:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(desktop): prevent PR chip label truncation (#101222)
Adam Bowkeraf6500917007
diff --git a/products/desktop/packages/ui/src/features/editor/components/GithubRefChip.stories.tsx b/products/desktop/packages/ui/src/features/editor/components/GithubRefChip.stories.tsxindex 0a3fa8b3436b..462f630bbbf4 100644--- a/products/desktop/packages/ui/src/features/editor/components/GithubRefChip.stories.tsx+++ b/products/desktop/packages/ui/src/features/editor/components/GithubRefChip.stories.tsx@@ -126,14 +126,14 @@ const LIFECYCLE_CASES: { number: number; details: PrRefDetails }[] = [export const InlineProse: Story = {render: () => (<div className="max-w-xl text-[15px] leading-6">- The task will update+ Checked<PrRefChip- href="https://github.com/example-org/example-repo/pull/123456789"+ href="https://github.com/example-org/example-repo/pull/123456"details={LIFECYCLE_CASES[0].details}>- #123456789+ PR#123456</PrRefChip>- . Check the result before the next run.+ .</div>),};diff --git a/products/desktop/packages/ui/src/features/editor/components/GithubRefChip.test.tsx b/products/desktop/packages/ui/src/features/editor/components/GithubRefChip.test.tsxindex be0de6ee0255..3e0cd30a3435 100644--- a/products/desktop/packages/ui/src/features/editor/components/GithubRefChip.test.tsx+++ b/products/desktop/packages/ui/src/features/editor/components/GithubRefChip.test.tsx@@ -29,9 +29,6 @@ describe("GithubRefChip", () => {const label = container.querySelector(".truncate");expect(label).toHaveTextContent("PostHog/posthog");expect(label).not.toHaveAttribute("dir");- expect(label).toHaveStyle({- maxWidth: "min(16rem, calc(100% - 1rem - 10ch))",- });const number = screen.getByText("#123456789");expect(number).toHaveClass("shrink-0");expect(number.parentElement).not.toHaveAttribute("dir");diff --git a/products/desktop/packages/ui/src/features/editor/components/GithubRefChip.tsx b/products/desktop/packages/ui/src/features/editor/components/GithubRefChip.tsxindex 544a2b79d06b..d9311504a192 100644--- a/products/desktop/packages/ui/src/features/editor/components/GithubRefChip.tsx+++ b/products/desktop/packages/ui/src/features/editor/components/GithubRefChip.tsx@@ -62,14 +62,7 @@ export const GithubRefChipLink = forwardRef<},ref,) {- // The number lives in its own span that cannot shrink, so a truncating label- // keeps the whole number readable instead of ellipsizing one end of it.const split = preservePrNumber ? splitRefNumber(children) : null;- // ch because the unit scales with the label's own font: the preserved number- // keeps roughly this many digits readable at any text size, and the label- // span's max-width subtracts the same width so a long number cannot push the- // chip past its cap.- const numberCh = split ? split[1].length : 0;return (<Buttonref={ref}@@ -88,36 +81,22 @@ export const GithubRefChipLink = forwardRef<}{...buttonProps}className={cn(- // overflow-hidden: nothing in the content box shrinks below its- // content size, so a long preserved number would otherwise paint past- // the chip edge.- "cli-file-mention focus-visible:-outline-offset-1 mx-0.5 inline-block max-w-full cursor-pointer! select-text overflow-hidden whitespace-nowrap pl-1.5 align-middle leading-[1.375rem] no-underline",+ "cli-file-mention focus-visible:-outline-offset-1 mx-0.5 inline-flex max-w-full cursor-pointer! select-text gap-0 overflow-hidden whitespace-nowrap pl-1.5 align-middle leading-[1.375rem] no-underline",buttonProps.className,)}><RefIconsize={12}weight="bold"- className={cn("mr-1 inline-block align-[-0.125em]", toneClass)}+ className={cn("mr-1", toneClass)}aria-label={iconLabel}aria-hidden={iconLabel ? undefined : true}role={iconLabel ? "img" : undefined}/>- <span- // 1rem is the icon and its margin, which share the chip's content box- // with the label; numberCh is the preserved number's width. Without- // those subtractions the label paints past the chip edge in a narrow- // panel instead of truncating.- className={cn("inline-block truncate align-top", toneClass)}- style={{- maxWidth: `min(16rem, calc(100% - 1rem - ${numberCh}ch))`,- }}- >+ <span className={cn("min-w-0 max-w-64 truncate", toneClass)}>{split ? split[0] : children}</span>- {split && (- <span className={cn("shrink-0 align-top", toneClass)}>{split[1]}</span>- )}+ {split && <span className={cn("shrink-0", toneClass)}>{split[1]}</span>}</Button>);});