Breadcrumb title truncation (DES-93)
Pre-release · Type: ✨ Feature
DES-93 (sub issue of DES-92 Breadcrumb)
Problem
The Breadcrumb item.title was laid out directly inside the flex container with no width constraint, so an overly long title would stretch the breadcrumb indefinitely. The Label text node of Figma's Breadcrumbs Base is spec'd as maxWidth: 260 + textTruncation: ENDING (truncate with a trailing ellipsis beyond 260px), which the component did not implement.
Changed Files
src/components/Breadcrumb/styles.tssrc/components/Breadcrumb/Breadcrumb.tsxsrc/components/Breadcrumb/Breadcrumb.test.tsxsrc/components/Breadcrumb/Breadcrumb.visual.spec.tsx(new)scripts/visual-diff-config.tseslint.config.jspackages/design-site/docs/components/atomic/breadcrumb.mdx(en + zh-CN)
Changes
- Added
BREADCRUMB_TITLE_CLASS(max-w-[260px] truncate); when rendering via the items API, the title is wrapped in a truncation span (a flex container cannot itself produce an ellipsis—truncation must land on the text node). For string-typed titles, the nativetitleattribute is also set so the full text can be viewed on hover. - Added truncation assertions to the unit tests (truncation class, native tooltip, no tooltip for non-string titles), and fixed the
getByTextassertion that broke because the title now has an extra span layer. - Added the visual test
Breadcrumb.visual.spec.tsxwith 5 cases: count-2 / count-4 / collapsed (4+ collapsed) / long-title (truncation + scrollWidth overflow assertion) / long-title-hover. - Added a Breadcrumb mapping to
visual-diff-config.ts(count-2 → Text variants21179:795+21179:792); count-4 / collapsed / long-title have no standalone Figma node. - Added
playwright/.cachetoeslint.config.jsignores (after running visual tests locally, the Playwright CT cache artifacts would break lint). - Code review fix: added the semantic class
plaud-breadcrumb-titleto the truncation span (test selectors now use it instead of relying on the.truncateutility class); supplemented the design-sitebreadcrumb.mdx(en + zh-CN) with an explanation and example of long-title truncation. - Code review improvement:
styles.tsexports theBREADCRUMB_TITLE_MAX_WIDTH = 260constant for test assertions (the Tailwind class still needs a literal value; a comment notes the two places must stay in sync);clipShotwas extracted from the Button / Breadcrumb visual specs into the sharedplaywright/visual-utils.ts.
Root Cause
The composition mode (children passed through directly) is unaffected—callers control it themselves; only the default render path of the items API takes over truncation.