From 48c1a33eb0487fe2e29e1c36c3abb29d2c6dd1c3 Mon Sep 17 00:00:00 2001 From: Josh Date: Sat, 14 Nov 2026 22:39:34 -0600 Subject: [PATCH 1/7] fix(Text): preserve words in single-line truncation --- .changeset/single-line-word-break.md | 7 +++++++ docs/specs/components/Heading/Heading.spec.md | 2 +- docs/specs/components/Text/Text.spec.md | 2 +- packages/core/src/Heading/Heading.test.tsx | 17 +++++++++++++++-- packages/core/src/Heading/Heading.tsx | 8 ++++---- packages/core/src/Text/Heading.doc.mjs | 2 +- packages/core/src/Text/Text.doc.mjs | 2 +- packages/core/src/Text/Text.test.tsx | 18 +++++++++++++++--- packages/core/src/Text/Text.tsx | 8 ++++---- .../__tests__/TextReflow.a11y.chromium.spec.ts | 9 ++++++++- 10 files changed, 57 insertions(+), 18 deletions(-) create mode 100644 .changeset/single-line-word-break.md diff --git a/.changeset/single-line-word-break.md b/.changeset/single-line-word-break.md new file mode 100644 index 0000000000000..06cf7d455ab31 --- /dev/null +++ b/.changeset/single-line-word-break.md @@ -0,0 +1,7 @@ +--- +'@astryxdesign/core': patch +--- + +[fix] Keep single-line Text and Heading truncation from splitting words when wrapping is restored + +@bezabyte diff --git a/docs/specs/components/Heading/Heading.spec.md b/docs/specs/components/Heading/Heading.spec.md index db61bd93786a6..50b40bb11e7b7 100644 --- a/docs/specs/components/Heading/Heading.spec.md +++ b/docs/specs/components/Heading/Heading.spec.md @@ -112,7 +112,7 @@ Consumer migration instructions belong in consumer docs and release notes. | FR1 | `level` renders `h1`–`h6`. `accessibilityLevel` adds `aria-level` only when it differs from `level`. | Current source and tests | | FR2 | The heading carries the `heading` target reflecting `level`, `color`, and any supplied `type` and `weight`. A built-in `type` applies its display scale and default weight; otherwise the level's scale applies. A theme-added `type` keeps the level's scale as its baseline. An explicit `weight` wins over the type and level defaults. | Current source and tests | | FR3 | `color` defaults to `primary`; a theme-added color keeps the primary baseline until a theme paints it. `hasCapsize` renders `block` and trims to cap height; otherwise `maxLines` above 1 renders the line-clamp box, `maxLines={1}` renders `block`, and otherwise `display` (default `block`) applies. `justify` uses logical values; `start`, the default, sets no alignment, so the element follows its container's. `textWrap` and `hasStrikethrough` apply their text treatments. Without truncation, a token longer than its line wraps, so in ordinary flow the text does not force horizontal scrolling at 320 CSS px (`spec:AST-020` FR1, WCAG 2.2 1.4.10 Reflow). The heading's `overflow-wrap` is `break-word`, which keeps min-content, so tables and auto-sized columns lay out ordinary words unchanged; inside a Core container that wraps its content with `anywhere` (CommandPaletteEmpty, Toast, FieldStatus, Banner), it is `anywhere`, as the container's own text is. A flex child needs `min-width: 0` from its container, and a caller's own container that sets `overflow-wrap: anywhere` does not reach the heading's text. | Current source and tests | -| FR4 | `maxLines={1}` clips one line with an ellipsis; a larger value clamps to that many lines unless `hasCapsize` is set, whose `block` display removes the clamp. With truncation, `wordBreak` defaults to `break-all` for one line and `break-word` otherwise. When the text is measured as truncated and `hasTruncateTooltip` is not `false`, a lazily loaded Tooltip anchored to the heading shows the full text at the given placement (default `above`); no native `title` is added. `hasTruncateTooltip={false}` takes no measurement. A truncation tooltip can be opened from the keyboard (WCAG 2.2 2.1.1). Implementation gap: the tooltip opens on hover and touch only, because the heading is not focusable (Current-state impact). | Current source and tests | +| FR4 | `maxLines={1}` clips one line with an ellipsis; a larger value clamps to that many lines unless `hasCapsize` is set, whose `block` display removes the clamp. With truncation, `wordBreak` defaults to `break-word` for both one line and multiple lines; callers can pass `break-all` when splitting inside words is intentional. When the text is measured as truncated and `hasTruncateTooltip` is not `false`, a lazily loaded Tooltip anchored to the heading shows the full text at the given placement (default `above`); no native `title` is added. `hasTruncateTooltip={false}` takes no measurement. A truncation tooltip can be opened from the keyboard (WCAG 2.2 2.1.1). Implementation gap: the tooltip opens on hover and touch only, because the heading is not focusable (Current-state impact). | Current source and tests | | FR5 | `ref` reaches the heading element. Supported DOM, ARIA, data, and event props reach it after the derived `aria-level`, so a caller `aria-level` wins; `xstyle`, `className`, and `style` merge in that order after component styles, with the line clamp applied after `style`. | Current source and tests | ### Allowed variation diff --git a/docs/specs/components/Text/Text.spec.md b/docs/specs/components/Text/Text.spec.md index f2cd6c35f8940..69e660816e9cf 100644 --- a/docs/specs/components/Text/Text.spec.md +++ b/docs/specs/components/Text/Text.spec.md @@ -115,7 +115,7 @@ Consumer migration instructions belong in consumer docs and release notes. | FR1 | Text renders one element chosen by `as` (default `span`) carrying the `text` target, which reflects `type`, `size`, and the resolved `color`. | Current source and tests | | FR2 | A built-in `type` applies its size, line height, and default weight; a theme-added type applies the body baseline. `size` overrides the type's size while keeping its other properties; `weight` overrides the type's default weight. The resolved color is `color`, else the type's default; a theme-added color applies the primary baseline. | Current source and tests | | FR3 | `hasCapsize` renders `block` and trims to cap height; otherwise `maxLines` above 1 renders the line-clamp box, `maxLines={1}` renders `block`, and otherwise `display` (default `inline`) applies. `justify` uses logical values; `start`, the default, sets no alignment, so the element follows its container's. `textWrap`, `hasStrikethrough`, and `hasTabularNumbers` apply their text treatments. Without truncation, a token longer than its line wraps, so in ordinary flow the text does not force horizontal scrolling at 320 CSS px (`spec:AST-020` FR1, WCAG 2.2 1.4.10 Reflow). The element's `overflow-wrap` is `break-word`, which keeps min-content, so tables and auto-sized columns lay out ordinary words unchanged; inside a Core container that wraps its content with `anywhere` (CommandPaletteEmpty, Toast, FieldStatus, Banner), it is `anywhere`, as the container's own text is. A flex child needs `min-width: 0` from its container, and a caller's own container that sets `overflow-wrap: anywhere` does not reach the element's text. | Current source and tests | -| FR4 | `maxLines={1}` clips one line with an ellipsis; a larger value clamps to that many lines unless `hasCapsize` is set, whose `block` display removes the clamp. With truncation, `wordBreak` defaults to `break-all` for one line and `break-word` otherwise. When the text is measured as truncated and `hasTruncateTooltip` is not `false`, a lazily loaded Tooltip anchored to the element shows the full text at the given placement (default `above`), and Text adds no native `title`. `hasTruncateTooltip={false}` takes no measurement. A truncation tooltip can be opened from the keyboard (WCAG 2.2 2.1.1). Implementation gap: the tooltip opens on hover and touch only, because the element is not focusable (Current-state impact). Truncation re-measures when the content changes without a resize. | Current source and tests | +| FR4 | `maxLines={1}` clips one line with an ellipsis; a larger value clamps to that many lines unless `hasCapsize` is set, whose `block` display removes the clamp. With truncation, `wordBreak` defaults to `break-word` for both one line and multiple lines; callers can pass `break-all` when splitting inside words is intentional. When the text is measured as truncated and `hasTruncateTooltip` is not `false`, a lazily loaded Tooltip anchored to the element shows the full text at the given placement (default `above`), and Text adds no native `title`. `hasTruncateTooltip={false}` takes no measurement. A truncation tooltip can be opened from the keyboard (WCAG 2.2 2.1.1). Implementation gap: the tooltip opens on hover and touch only, because the element is not focusable (Current-state impact). Truncation re-measures when the content changes without a resize. | Current source and tests | | FR5 | `ref` reaches the element. Supported DOM, ARIA, data, and event props reach it; `xstyle`, `className`, and `style` merge in that order after component styles, with the line clamp applied after `style`. | Current source and tests | ### Allowed variation diff --git a/packages/core/src/Heading/Heading.test.tsx b/packages/core/src/Heading/Heading.test.tsx index 6f7e32bec2e69..8e0d491f73fc3 100644 --- a/packages/core/src/Heading/Heading.test.tsx +++ b/packages/core/src/Heading/Heading.test.tsx @@ -322,7 +322,7 @@ describe('Heading long unbroken tokens', () => { expect(wrapOf(screen.getByText(token))).toBe(DEFAULT_WRAP); }); - it('leaves single-line truncation clipping on one line', () => { + it('keeps single-line truncation on one line by default', () => { render( {token} @@ -331,7 +331,20 @@ describe('Heading long unbroken tokens', () => { const style = getComputedStyle(screen.getByText(token)); expect(style.whiteSpace).toBe('nowrap'); expect(style.textOverflow).toBe('ellipsis'); - expect(style.overflowWrap).not.toBe('break-word'); + expect(style.wordBreak).toBe('normal'); + expect(style.overflowWrap).toBe('break-word'); + }); + + it('preserves word boundaries when a caller allows the line to wrap', () => { + render( + + {token} + , + ); + const style = getComputedStyle(screen.getByText(token)); + expect(style.whiteSpace).toBe('normal'); + expect(style.wordBreak).toBe('normal'); + expect(style.overflowWrap).toBe('break-word'); }); }); diff --git a/packages/core/src/Heading/Heading.tsx b/packages/core/src/Heading/Heading.tsx index de84c5ad97c8c..9fd3b18899fee 100644 --- a/packages/core/src/Heading/Heading.tsx +++ b/packages/core/src/Heading/Heading.tsx @@ -155,7 +155,7 @@ export interface HeadingProps extends Omit< /** * Word break behavior for truncated text. - * @default 'break-all' for maxLines=1, 'break-word' otherwise + * @default 'break-word' */ wordBreak?: WordBreak; @@ -244,9 +244,9 @@ export function Heading({ ? {'aria-level': accessibilityLevel} : {}; - // Resolve wordBreak with smart default - const resolvedWordBreak = - wordBreak ?? (maxLines === 1 ? 'break-all' : 'break-word'); + // A single-line clamp already prevents wrapping. Keep the default word + // boundary behavior consistent if a caller later allows the line to wrap. + const resolvedWordBreak = wordBreak ?? 'break-word'; // Resolve display - force block when maxLines > 0 or hasCapsize const resolvedDisplay = maxLines > 0 || hasCapsize ? 'block' : display; diff --git a/packages/core/src/Text/Heading.doc.mjs b/packages/core/src/Text/Heading.doc.mjs index df602a522d83e..4ad3050a972dc 100644 --- a/packages/core/src/Text/Heading.doc.mjs +++ b/packages/core/src/Text/Heading.doc.mjs @@ -82,7 +82,7 @@ export const docs = { name: 'wordBreak', type: "'break-word' | 'break-all'", description: - "Word break behavior when truncating. Defaults to 'break-all' for single-line truncation, 'break-word' otherwise. Without truncation, a token longer than its line (a URL, an ID) wraps (`overflow-wrap: break-word`), so in ordinary flow text does not make the page scroll sideways. Inside a flex row, give the flex child `min-width: 0` so it can shrink. A container you style with `overflow-wrap: anywhere` does not reach this text; Astryx's own containers pass their wrap through.", + "Word break behavior when truncating. Defaults to 'break-word' for both single-line and multi-line truncation; pass 'break-all' when splitting inside words is intentional. Without truncation, a token longer than its line (a URL, an ID) wraps (`overflow-wrap: break-word`), so in ordinary flow text does not make the page scroll sideways. Inside a flex row, give the flex child `min-width: 0` so it can shrink. A container you style with `overflow-wrap: anywhere` does not reach this text; Astryx's own containers pass their wrap through.", }, { name: 'textWrap', diff --git a/packages/core/src/Text/Text.doc.mjs b/packages/core/src/Text/Text.doc.mjs index bd2b8f0b8a31f..f68165f68570e 100644 --- a/packages/core/src/Text/Text.doc.mjs +++ b/packages/core/src/Text/Text.doc.mjs @@ -118,7 +118,7 @@ export const docs = { name: 'wordBreak', type: "'break-word' | 'break-all'", description: - "Word break behavior when truncating. Defaults to 'break-all' for single-line truncation, 'break-word' otherwise. Without truncation, a token longer than its line (a URL, an ID) wraps (`overflow-wrap: break-word`), so in ordinary flow text does not make the page scroll sideways. Inside a flex row, give the flex child `min-width: 0` so it can shrink. A container you style with `overflow-wrap: anywhere` does not reach this text; Astryx's own containers pass their wrap through.", + "Word break behavior when truncating. Defaults to 'break-word' for both single-line and multi-line truncation; pass 'break-all' when splitting inside words is intentional. Without truncation, a token longer than its line (a URL, an ID) wraps (`overflow-wrap: break-word`), so in ordinary flow text does not make the page scroll sideways. Inside a flex row, give the flex child `min-width: 0` so it can shrink. A container you style with `overflow-wrap: anywhere` does not reach this text; Astryx's own containers pass their wrap through.", }, { name: 'textWrap', diff --git a/packages/core/src/Text/Text.test.tsx b/packages/core/src/Text/Text.test.tsx index aaf1fc1aaed55..06eeacc6e7708 100644 --- a/packages/core/src/Text/Text.test.tsx +++ b/packages/core/src/Text/Text.test.tsx @@ -250,13 +250,25 @@ describe('Text', () => { expect(wrapOf(screen.getByText(`${token}/block`))).toBe(DEFAULT_WRAP); }); - it('leaves single-line truncation clipping on one line', () => { + it('keeps single-line truncation on one line by default', () => { render({token}); const style = getComputedStyle(screen.getByText(token)); expect(style.whiteSpace).toBe('nowrap'); expect(style.textOverflow).toBe('ellipsis'); - expect(style.wordBreak).toBe('break-all'); - expect(style.overflowWrap).not.toBe('break-word'); + expect(style.wordBreak).toBe('normal'); + expect(style.overflowWrap).toBe('break-word'); + }); + + it('preserves word boundaries when a caller allows the line to wrap', () => { + render( + + {token} + , + ); + const style = getComputedStyle(screen.getByText(token)); + expect(style.whiteSpace).toBe('normal'); + expect(style.wordBreak).toBe('normal'); + expect(style.overflowWrap).toBe('break-word'); }); }); diff --git a/packages/core/src/Text/Text.tsx b/packages/core/src/Text/Text.tsx index 2ebc2776ec257..256fa1189e488 100644 --- a/packages/core/src/Text/Text.tsx +++ b/packages/core/src/Text/Text.tsx @@ -116,7 +116,7 @@ export interface TextProps extends Omit { /** * Word break behavior for truncated text. - * @default 'break-all' for maxLines=1, 'break-word' otherwise + * @default 'break-word' */ wordBreak?: WordBreak; @@ -255,9 +255,9 @@ export function Text({ // class (see themeProps below). const styleColor = resolveStyleColor(resolvedColor); - // Resolve wordBreak with smart default - const resolvedWordBreak = - wordBreak ?? (maxLines === 1 ? 'break-all' : 'break-word'); + // A single-line clamp already prevents wrapping. Keep the default word + // boundary behavior consistent if a caller later allows the line to wrap. + const resolvedWordBreak = wordBreak ?? 'break-word'; // Resolve display - force block when maxLines > 0 or hasCapsize const resolvedDisplay = maxLines > 0 || hasCapsize ? 'block' : display; diff --git a/packages/core/src/Text/__tests__/TextReflow.a11y.chromium.spec.ts b/packages/core/src/Text/__tests__/TextReflow.a11y.chromium.spec.ts index f1387200ee941..081319b58b464 100644 --- a/packages/core/src/Text/__tests__/TextReflow.a11y.chromium.spec.ts +++ b/packages/core/src/Text/__tests__/TextReflow.a11y.chromium.spec.ts @@ -114,9 +114,16 @@ test('single-line truncation still clips the token on one line at 320 px', async return { whiteSpace: computed.whiteSpace, textOverflow: computed.textOverflow, + wordBreak: computed.wordBreak, + overflowWrap: computed.overflowWrap, }; }); - expect(style, id).toEqual({whiteSpace: 'nowrap', textOverflow: 'ellipsis'}); + expect(style, id).toEqual({ + whiteSpace: 'nowrap', + textOverflow: 'ellipsis', + wordBreak: 'normal', + overflowWrap: 'break-word', + }); expect(await lineCount(target), id).toBe(1); expect( await target.evaluate( From ea12305ac0bd75bdaf5f1876f84778312fd6f56f Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 15 Nov 2026 22:30:13 -0600 Subject: [PATCH 2/7] docs(Text): align word-break defaults --- .changeset/single-line-word-break.md | 2 +- apps/storybook/stories/Text.stories.tsx | 4 ++-- .../assets/templates/blocks/components/Text/TextWordBreak.tsx | 4 ++-- packages/core/src/Text/Heading.doc.mjs | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.changeset/single-line-word-break.md b/.changeset/single-line-word-break.md index 06cf7d455ab31..a0c91c8f7946a 100644 --- a/.changeset/single-line-word-break.md +++ b/.changeset/single-line-word-break.md @@ -2,6 +2,6 @@ '@astryxdesign/core': patch --- -[fix] Keep single-line Text and Heading truncation from splitting words when wrapping is restored +[feat] Change the single-line Text and Heading truncation default from `break-all` to `break-word`; pass `wordBreak="break-all"` to opt into splitting inside words @bezabyte diff --git a/apps/storybook/stories/Text.stories.tsx b/apps/storybook/stories/Text.stories.tsx index 2e62a62d6ac34..de21cb7be366b 100644 --- a/apps/storybook/stories/Text.stories.tsx +++ b/apps/storybook/stories/Text.stories.tsx @@ -410,7 +410,7 @@ export const WordBreakVariants: Story = {
- break-word (default for multi-line): + break-word (default for truncation):
@@ -420,7 +420,7 @@ export const WordBreakVariants: Story = {
- break-all (default for single-line): + break-all (explicit opt-in):
diff --git a/packages/cli/assets/templates/blocks/components/Text/TextWordBreak.tsx b/packages/cli/assets/templates/blocks/components/Text/TextWordBreak.tsx index 7e71a70a89b6d..42ad4d27f005c 100644 --- a/packages/cli/assets/templates/blocks/components/Text/TextWordBreak.tsx +++ b/packages/cli/assets/templates/blocks/components/Text/TextWordBreak.tsx @@ -15,7 +15,7 @@ export default function TextWordBreak() { }}>
- Break-word (default for multi-line) + Break-word (default for all truncation)
@@ -25,7 +25,7 @@ export default function TextWordBreak() {
- Break-all (default for single-line) + Break-all (explicit opt-in)
diff --git a/packages/core/src/Text/Heading.doc.mjs b/packages/core/src/Text/Heading.doc.mjs index 4ad3050a972dc..f78c221635baa 100644 --- a/packages/core/src/Text/Heading.doc.mjs +++ b/packages/core/src/Text/Heading.doc.mjs @@ -206,7 +206,7 @@ export const docsZh = { name: 'wordBreak', type: "'break-word' | 'break-all'", description: - "截断时的断词行为。单行截断默认为 'break-all',其他情况默认为 'break-word'。不截断时,超过一行宽度的长串(如 URL、ID)会换行(`overflow-wrap: break-word`),因此在普通文档流中文本不会让页面横向滚动。在 flex 行中,请为 flex 子元素设置 `min-width: 0` 以便其收缩。你自己设置了 `overflow-wrap: anywhere` 的容器不会作用于此文本;Astryx 自带的容器会传递其换行方式。", + "截断时的断词行为。单行和多行截断都默认为 'break-word';如果确实要在单词内部断开,请传入 'break-all'。不截断时,超过一行宽度的长串(如 URL、ID)会换行(`overflow-wrap: break-word`),因此在普通文档流中文本不会让页面横向滚动。在 flex 行中,请为 flex 子元素设置 `min-width: 0` 以便其收缩。你自己设置了 `overflow-wrap: anywhere` 的容器不会作用于此文本;Astryx 自带的容器会传递其换行方式。", }, { name: 'textWrap', @@ -284,7 +284,7 @@ export const docsDense = { hasTruncateTooltip: "Tooltip for truncated text; true=default position, false=disabled, or a placement ('above' | 'below' | 'start' | 'end').", wordBreak: - "Word break behavior when truncating; defaults 'break-all' for single-line, 'break-word' otherwise. Untruncated long tokens wrap (overflow-wrap: break-word); a flex child needs min-width: 0; your own container's overflow-wrap: anywhere does not reach this text (Astryx containers pass theirs through).", + "Word break behavior when truncating; defaults 'break-word' for both single-line and multi-line truncation. Pass 'break-all' when splitting inside words is intentional. Untruncated long tokens wrap (overflow-wrap: break-word); a flex child needs min-width: 0; your own container's overflow-wrap: anywhere does not reach this text (Astryx containers pass theirs through).", textWrap: 'Text wrapping behavior.', justify: "Text alignment (justification); logical values 'start' | 'center' | 'end' for RTL.", From 5e73e2ee96043a1470f7534dcc42862540ab5963 Mon Sep 17 00:00:00 2001 From: Cindy Zhang Date: Thu, 3 Dec 2026 20:47:01 -0800 Subject: [PATCH 3/7] Name @astryxdesign/cli in the word-break changeset The TextWordBreak CLI example ships in @astryxdesign/cli, so the changeset must name that package too. --- .changeset/single-line-word-break.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.changeset/single-line-word-break.md b/.changeset/single-line-word-break.md index a0c91c8f7946a..345f742ff3bbe 100644 --- a/.changeset/single-line-word-break.md +++ b/.changeset/single-line-word-break.md @@ -1,4 +1,5 @@ --- +'@astryxdesign/cli': patch '@astryxdesign/core': patch --- From e5748e15a972d577847c508544e9c15a7677b648 Mon Sep 17 00:00:00 2001 From: Cindy Zhang Date: Thu, 3 Dec 2026 21:32:34 -0800 Subject: [PATCH 4/7] Name the wrap tests for what they check; use Astryx layout in TextWordBreak A word wider than the line still wraps inside itself, so the tests check that lines break between words, not that words stay whole. The TextWordBreak block uses VStack and Card instead of raw divs with inline styles. --- .../blocks/components/Text/TextWordBreak.tsx | 36 ++++++++----------- packages/core/src/Heading/Heading.test.tsx | 2 +- packages/core/src/Text/Text.test.tsx | 2 +- 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/packages/cli/assets/templates/blocks/components/Text/TextWordBreak.tsx b/packages/cli/assets/templates/blocks/components/Text/TextWordBreak.tsx index 42ad4d27f005c..5794fdfb74cbc 100644 --- a/packages/cli/assets/templates/blocks/components/Text/TextWordBreak.tsx +++ b/packages/cli/assets/templates/blocks/components/Text/TextWordBreak.tsx @@ -2,37 +2,29 @@ 'use client'; +import {Card} from '@astryxdesign/core/Card'; +import {VStack} from '@astryxdesign/core/Stack'; import {Text} from '@astryxdesign/core/Text'; export default function TextWordBreak() { return ( -
-
- - Break-word (default for all truncation) - -
+ + + Break-word (default for all truncation) + This is a verylongunbreakableword for a break-word example -
-
-
- - Break-all (explicit opt-in) - -
+ + + + Break-all (explicit opt-in) + Breaks anywhere: abcdefghijklmnopqrstuvwxyz0123456789 -
-
-
+ + + ); } diff --git a/packages/core/src/Heading/Heading.test.tsx b/packages/core/src/Heading/Heading.test.tsx index 8e0d491f73fc3..73256ec875515 100644 --- a/packages/core/src/Heading/Heading.test.tsx +++ b/packages/core/src/Heading/Heading.test.tsx @@ -335,7 +335,7 @@ describe('Heading long unbroken tokens', () => { expect(style.overflowWrap).toBe('break-word'); }); - it('preserves word boundaries when a caller allows the line to wrap', () => { + it('breaks between words when a caller allows the line to wrap', () => { render( {token} diff --git a/packages/core/src/Text/Text.test.tsx b/packages/core/src/Text/Text.test.tsx index 06eeacc6e7708..cd4194aabcdc0 100644 --- a/packages/core/src/Text/Text.test.tsx +++ b/packages/core/src/Text/Text.test.tsx @@ -259,7 +259,7 @@ describe('Text', () => { expect(style.overflowWrap).toBe('break-word'); }); - it('preserves word boundaries when a caller allows the line to wrap', () => { + it('breaks between words when a caller allows the line to wrap', () => { render( {token} From 5460972a205d85747c7684dc48b8bd183ca61b84 Mon Sep 17 00:00:00 2001 From: Cindy Zhang Date: Thu, 3 Dec 2026 23:45:06 -0800 Subject: [PATCH 5/7] Record the word-break default change; pin the break-all opt-in The Text and Heading records now say the maxLines={1} default changed from break-all to break-word, a nonbreaking typography default, and that wordBreak="break-all" keeps the old split. The wrap tests use a sentence, a new test covers the break-all opt-in, the source comment says what happens when a caller restores wrapping, and the TextWordBreak block lists Card and Stack. --- docs/specs/components/Heading/Heading.spec.md | 27 ++++++++++--------- docs/specs/components/Text/Text.spec.md | 27 ++++++++++--------- .../components/Text/TextWordBreak.doc.mjs | 2 +- packages/core/src/Heading/Heading.test.tsx | 17 ++++++++++-- packages/core/src/Heading/Heading.tsx | 4 +-- packages/core/src/Text/Text.test.tsx | 17 ++++++++++-- packages/core/src/Text/Text.tsx | 4 +-- 7 files changed, 65 insertions(+), 33 deletions(-) diff --git a/docs/specs/components/Heading/Heading.spec.md b/docs/specs/components/Heading/Heading.spec.md index 66665098f3532..0761a815f9c86 100644 --- a/docs/specs/components/Heading/Heading.spec.md +++ b/docs/specs/components/Heading/Heading.spec.md @@ -35,15 +35,15 @@ system_specs: [spec:AST-009, spec:AST-024] ## Contract at a glance -| Area | Contract | -| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Public contract | A semantic heading with a required `level`, an optional theme-extensible visual `type`, `weight`, `accessibilityLevel`, and the shared text controls documented in `Heading.doc.mjs`. | -| Behavior | `level` picks `h1`–`h6` and the default visual scale; `type` and `weight` change only appearance; `accessibilityLevel` sets `aria-level` when it differs. | -| End-user impact | Screen-reader users navigate a document outline that matches the page's sections, whatever size each heading is drawn at. | -| Builder impact | A long unbroken token in non-truncated Heading wraps. Inside a flex row, the flex child needs `min-width: 0` for the wrap to apply, and a caller's own container that sets `overflow-wrap: anywhere` does not reach Heading's text; Core's `anywhere` containers pass their wrap to it. The truncation Tooltip mounts on the first hover, completed tap or focus (AR3). | -| Compatibility/readiness | Released behavior recorded as current, with one styling output change and one DOM change: non-truncated Heading sets `overflow-wrap` (`break-word`, or `anywhere` inside Core's `anywhere` containers). The truncation Tooltip mounts on the first hover, completed tap or focus, so until then a clamped Heading has no tooltip layer, and it never adds `aria-describedby` (AR3). No API change. One implementation gap is listed under Current-state impact. | -| Review checks | Reject a visual `type` or `weight` that changes the element or level, a heading that renders without a level baseline, or a duplicate native tooltip for truncation. | -| Governing rules | `spec:AST-024` (custom visual types, weight precedence, unchanged accessibility); `architecture:component-theming-surface/INV6,INV14`; `architecture:public-component-api/INV5,INV6,INV8`. | +| Area | Contract | +| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Public contract | A semantic heading with a required `level`, an optional theme-extensible visual `type`, `weight`, `accessibilityLevel`, and the shared text controls documented in `Heading.doc.mjs`. | +| Behavior | `level` picks `h1`–`h6` and the default visual scale; `type` and `weight` change only appearance; `accessibilityLevel` sets `aria-level` when it differs. | +| End-user impact | Screen-reader users navigate a document outline that matches the page's sections, whatever size each heading is drawn at. | +| Builder impact | A long unbroken token in non-truncated Heading wraps. Inside a flex row, the flex child needs `min-width: 0` for the wrap to apply, and a caller's own container that sets `overflow-wrap: anywhere` does not reach Heading's text; Core's `anywhere` containers pass their wrap to it. The truncation Tooltip mounts on the first hover, completed tap or focus (AR3). | +| Compatibility/readiness | Released behavior recorded as current, with one styling output change and one DOM change: non-truncated Heading sets `overflow-wrap` (`break-word`, or `anywhere` inside Core's `anywhere` containers). The truncation Tooltip mounts on the first hover, completed tap or focus, so until then a clamped Heading has no tooltip layer, and it never adds `aria-describedby` (AR3). No prop change. One default change: with `maxLines={1}`, `wordBreak` defaults to `break-word` instead of `break-all` (FR4), a nonbreaking typography default; `wordBreak="break-all"` keeps the old split. One implementation gap is listed under Current-state impact. | +| Review checks | Reject a visual `type` or `weight` that changes the element or level, a heading that renders without a level baseline, or a duplicate native tooltip for truncation. | +| Governing rules | `spec:AST-024` (custom visual types, weight precedence, unchanged accessibility); `architecture:component-theming-surface/INV6,INV14`; `architecture:public-component-api/INV5,INV6,INV8`. | This table is a review projection; the body below is authoritative. @@ -57,9 +57,12 @@ Heading's own contract. ## Compatibility and migration -- Released default preserved: `yes` -- Compatibility class: one styling output change and one DOM change, with - no public prop or default change: non-truncated Heading sets `overflow-wrap` +- Released default preserved: `no`: with `maxLines={1}`, `wordBreak` defaults + to `break-word` instead of `break-all` (FR4) +- Compatibility class: one styling output change, one DOM change and one + nonbreaking typography default change, with no public prop change. With + `maxLines={1}`, `wordBreak` defaults to `break-word` instead of `break-all`, + and `wordBreak="break-all"` keeps the old split (FR4). Non-truncated Heading sets `overflow-wrap` (`break-word`, or `anywhere` inside Core's `anywhere` containers), so a long unbroken token wraps (FR3). The truncation Tooltip mounts on the first hover, completed tap or focus (AR3): before that, a clamped Heading has no closed diff --git a/docs/specs/components/Text/Text.spec.md b/docs/specs/components/Text/Text.spec.md index 4c71e4db72f04..950ce5f7d786f 100644 --- a/docs/specs/components/Text/Text.spec.md +++ b/docs/specs/components/Text/Text.spec.md @@ -34,15 +34,15 @@ system_specs: [spec:AST-009] ## Contract at a glance -| Area | Contract | -| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Public contract | A polymorphic text element with a semantic `type`, optional `size`, `color`, and `weight` overrides, an `as` element choice, and the text layout controls documented in `Text.doc.mjs`. | -| Behavior | `type` sets size, weight, and default color from the theme; theme-added types and colors fall back to the body and primary baselines; truncated text offers its full content in a Tooltip. | -| End-user impact | Readers get consistent type across the product; clamped text keeps its full content available on hover and in the DOM. | -| Builder impact | A long unbroken token in non-truncated Text wraps. Inside a flex row, the flex child needs `min-width: 0` for the wrap to apply, and a caller's own container that sets `overflow-wrap: anywhere` does not reach Text's text; Core's `anywhere` containers pass their wrap to it. The truncation Tooltip mounts on the first hover, completed tap or focus (AR2). | -| Compatibility/readiness | Released behavior recorded as current, with one styling output change and one DOM change: non-truncated Text sets `overflow-wrap` (`break-word`, or `anywhere` inside Core's `anywhere` containers). The truncation Tooltip mounts on the first hover, completed tap or focus, so until then a clamped Text has no tooltip layer, and it never adds `aria-describedby` (AR2). No API change. One implementation gap is listed under Current-state impact. | -| Review checks | Reject a theme-added type or color that renders unstyled, a native `title` beside the truncation Tooltip, or measurement when the tooltip is off. | -| Governing rules | `architecture:component-theming-surface/INV6,INV14`; `architecture:public-component-api/INV5,INV6,INV8`. | +| Area | Contract | +| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Public contract | A polymorphic text element with a semantic `type`, optional `size`, `color`, and `weight` overrides, an `as` element choice, and the text layout controls documented in `Text.doc.mjs`. | +| Behavior | `type` sets size, weight, and default color from the theme; theme-added types and colors fall back to the body and primary baselines; truncated text offers its full content in a Tooltip. | +| End-user impact | Readers get consistent type across the product; clamped text keeps its full content available on hover and in the DOM. | +| Builder impact | A long unbroken token in non-truncated Text wraps. Inside a flex row, the flex child needs `min-width: 0` for the wrap to apply, and a caller's own container that sets `overflow-wrap: anywhere` does not reach Text's text; Core's `anywhere` containers pass their wrap to it. The truncation Tooltip mounts on the first hover, completed tap or focus (AR2). | +| Compatibility/readiness | Released behavior recorded as current, with one styling output change and one DOM change: non-truncated Text sets `overflow-wrap` (`break-word`, or `anywhere` inside Core's `anywhere` containers). The truncation Tooltip mounts on the first hover, completed tap or focus, so until then a clamped Text has no tooltip layer, and it never adds `aria-describedby` (AR2). No prop change. One default change: with `maxLines={1}`, `wordBreak` defaults to `break-word` instead of `break-all` (FR4), a nonbreaking typography default; `wordBreak="break-all"` keeps the old split. One implementation gap is listed under Current-state impact. | +| Review checks | Reject a theme-added type or color that renders unstyled, a native `title` beside the truncation Tooltip, or measurement when the tooltip is off. | +| Governing rules | `architecture:component-theming-surface/INV6,INV14`; `architecture:public-component-api/INV5,INV6,INV8`. | This table is a review projection; the body below is authoritative. @@ -55,9 +55,12 @@ the truncation behavior of that element. Heading is documented beside Text in ## Compatibility and migration -- Released default preserved: `yes` -- Compatibility class: one styling output change and one DOM change, with - no public prop or default change: non-truncated Text sets `overflow-wrap` +- Released default preserved: `no`: with `maxLines={1}`, `wordBreak` defaults + to `break-word` instead of `break-all` (FR4) +- Compatibility class: one styling output change, one DOM change and one + nonbreaking typography default change, with no public prop change. With + `maxLines={1}`, `wordBreak` defaults to `break-word` instead of `break-all`, + and `wordBreak="break-all"` keeps the old split (FR4). Non-truncated Text sets `overflow-wrap` (`break-word`, or `anywhere` inside Core's `anywhere` containers), so a long unbroken token wraps (FR3). The truncation Tooltip mounts on the first hover, completed tap or focus (AR2): before that, a clamped Text has no closed diff --git a/packages/cli/assets/templates/blocks/components/Text/TextWordBreak.doc.mjs b/packages/cli/assets/templates/blocks/components/Text/TextWordBreak.doc.mjs index 0761bf27aa70f..bea42b0b5038b 100644 --- a/packages/cli/assets/templates/blocks/components/Text/TextWordBreak.doc.mjs +++ b/packages/cli/assets/templates/blocks/components/Text/TextWordBreak.doc.mjs @@ -9,5 +9,5 @@ export const doc = { description: 'Compares break-word and break-all word break modes on a long unbreakable string.', isReady: true, aspectRatio: 16 / 9, - componentsUsed: ['Text'], + componentsUsed: ['Text', 'Card', 'Stack'], }; diff --git a/packages/core/src/Heading/Heading.test.tsx b/packages/core/src/Heading/Heading.test.tsx index 9b048fde0349e..986e5a881e511 100644 --- a/packages/core/src/Heading/Heading.test.tsx +++ b/packages/core/src/Heading/Heading.test.tsx @@ -336,16 +336,29 @@ describe('Heading long unbroken tokens', () => { }); it('breaks between words when a caller allows the line to wrap', () => { + const sentence = + 'Understanding accessibility requirements for design systems'; render( - {token} + {sentence} , ); - const style = getComputedStyle(screen.getByText(token)); + const style = getComputedStyle(screen.getByText(sentence)); expect(style.whiteSpace).toBe('normal'); expect(style.wordBreak).toBe('normal'); expect(style.overflowWrap).toBe('break-word'); }); + + it('splits inside words when a caller passes wordBreak="break-all"', () => { + render( + + {token} + , + ); + expect(getComputedStyle(screen.getByText(token)).wordBreak).toBe( + 'break-all', + ); + }); }); describe('Heading maxLines without a truncation tooltip', () => { diff --git a/packages/core/src/Heading/Heading.tsx b/packages/core/src/Heading/Heading.tsx index 3f51d4d61a6f0..84c21c5877ec8 100644 --- a/packages/core/src/Heading/Heading.tsx +++ b/packages/core/src/Heading/Heading.tsx @@ -267,8 +267,8 @@ export function Heading({ ? {'aria-level': accessibilityLevel} : {}; - // A single-line clamp already prevents wrapping. Keep the default word - // boundary behavior consistent if a caller later allows the line to wrap. + // A single-line clamp does not wrap. If a caller restores wrapping, + // lines break between words, as in a multi-line clamp. const resolvedWordBreak = wordBreak ?? 'break-word'; // Resolve display - force block when maxLines > 0 or hasCapsize diff --git a/packages/core/src/Text/Text.test.tsx b/packages/core/src/Text/Text.test.tsx index d5771beaee718..6752311d55e91 100644 --- a/packages/core/src/Text/Text.test.tsx +++ b/packages/core/src/Text/Text.test.tsx @@ -261,16 +261,29 @@ describe('Text', () => { }); it('breaks between words when a caller allows the line to wrap', () => { + const sentence = + 'Quarterly reliability review notes for the platform team'; render( - {token} + {sentence} , ); - const style = getComputedStyle(screen.getByText(token)); + const style = getComputedStyle(screen.getByText(sentence)); expect(style.whiteSpace).toBe('normal'); expect(style.wordBreak).toBe('normal'); expect(style.overflowWrap).toBe('break-word'); }); + + it('splits inside words when a caller passes wordBreak="break-all"', () => { + render( + + {token} + , + ); + expect(getComputedStyle(screen.getByText(token)).wordBreak).toBe( + 'break-all', + ); + }); }); it('renders the stable target and type data attribute for theme targeting', () => { diff --git a/packages/core/src/Text/Text.tsx b/packages/core/src/Text/Text.tsx index e8cc4c11d5408..3aacc7012f5ad 100644 --- a/packages/core/src/Text/Text.tsx +++ b/packages/core/src/Text/Text.tsx @@ -258,8 +258,8 @@ export function Text({ // class (see themeProps below). const styleColor = resolveStyleColor(resolvedColor); - // A single-line clamp already prevents wrapping. Keep the default word - // boundary behavior consistent if a caller later allows the line to wrap. + // A single-line clamp does not wrap. If a caller restores wrapping, + // lines break between words, as in a multi-line clamp. const resolvedWordBreak = wordBreak ?? 'break-word'; // Resolve display - force block when maxLines > 0 or hasCapsize From 7e8bb53c93704e8f715f33794d8b1eeab2f5218e Mon Sep 17 00:00:00 2001 From: Cindy Zhang Date: Fri, 4 Dec 2026 00:48:11 -0800 Subject: [PATCH 6/7] Name the tested word-break defaults in the verification maps The new tests pin the one-line wordBreak default and the break-all opt-in, so only the multi-line default stays a gap. --- docs/specs/components/Heading/Heading.spec.md | 24 +++++++++---------- docs/specs/components/Text/Text.spec.md | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/specs/components/Heading/Heading.spec.md b/docs/specs/components/Heading/Heading.spec.md index 0761a815f9c86..47d70b7761fa3 100644 --- a/docs/specs/components/Heading/Heading.spec.md +++ b/docs/specs/components/Heading/Heading.spec.md @@ -192,18 +192,18 @@ Tooltip. ## Verification map -| Contract | Verification | Representative states | Mutation or failure expectation | Audit section | -| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------ | -| FR1, AR2 | `Heading.test.tsx` level and `accessibilityLevel` tests | Levels 1–6; differing and equal override | A wrong element, a missing `aria-level` for a differing override, or an `aria-level` added for an equal one fails. | `audit:Heading/a11y` | -| FR2 | `Heading.test.tsx` target, type, theme-added type, weight, and omitted-type tests; `extensibleAxes.test.ts`; `HeadingAudit.a11y.chromium.spec.ts` on the AuditMatrix story | Display types, theme-added type, weight | A lost `heading` class or `data-level`, `data-color`, `data-type`, or `data-weight` reflection, a reflected omitted type, or a theme-added type losing its level baseline fails. Display sizes out of order, or an explicit `bold` no heavier than the display default, fails the browser spec. Gap: the level scales and the level default weights have no paint check. | `audit:Heading/theming` | -| FR3 | Stable visual baseline `core-heading--level-1`; `Heading.stories.tsx`; `HeadingAudit.a11y.chromium.spec.ts` | Level 1 default; secondary color; `center` and `end` alignment | A changed level-1 scale, color, or display comes back changed for review; a `justify` that does not resolve to logical `center` or `end`, or heading text below its WCAG contrast threshold, fails the browser spec. Gap: `display` precedence, `textWrap`, cap-height trim, strikethrough, and the theme-added color baseline have no automated check. | `audit:Heading/behavior` | -| FR3 (reflow) | `Heading.test.tsx` long unbroken tokens; `TextReflow.a11y.chromium.spec.ts`; `scripts/text-overflow-wrap-anywhere.test.mjs` | A long unbroken token, untruncated and single-line truncated, at 320 CSS px; Text inside CommandPaletteEmpty and Banner | A token that does not wrap in an untruncated heading, a page that scrolls sideways at 320 px, single-line truncation that no longer clips on one line, Text inside CommandPaletteEmpty or Banner that loses the container's `anywhere` wrap or crosses an inline edge, or a Core style that sets `overflow-wrap: anywhere` without passing it to Text, fails. | `audit:Heading/a11y` | -| FR4, PR1 | `Heading.test.tsx` truncation-measurement tests; `useTruncation.test.tsx`; `HeadingAudit.a11y.chromium.spec.ts` | Tooltip on and off; content change; one and two lines | Measuring with the tooltip off, not measuring with it on, or a missed re-measure fails. A one-line heading without its ellipsis, a two-line clamp that does not hold two lines, or a clipped heading whose hover shows no full-text tooltip fails the browser spec. Gap: the `wordBreak` defaults and the tooltip placement have no automated check. | `audit:Heading/behavior` | -| AR3 (tooltip mount), PR1 | `Heading.test.tsx` "the truncation tooltip mounts on the first interaction" case: no tooltip layer before any interaction, one on the first hover; the shared mount behavior is covered by the `Text.test.tsx` cases, since Text and Heading share `TruncationTooltip` | Truncated before and after the first hover, tap, or focus | A tooltip layer before the first interaction, a tooltip description at any time, or a first hover, tap or focus that does not open the Tooltip by its own rules, fails. Gap: no accessibility-tree check of the description (`spec:AST-009` FR3). | `audit:Heading/a11y` | -| FR5 | `Heading.test.tsx` ref, `id`, passthrough, `aria-level` precedence, styling-input, and line-clamp tests | Rerender; `id`; `data-testid`; caller `aria-level`; `className`, `xstyle`, and `style` | A detached ref, a lost `id` or test id, a derived `aria-level` that overrides the caller's, a `className` or `xstyle` that is dropped or merges before the component styles, or a caller `WebkitLineClamp` that replaces the clamp fails. | `audit:Heading/behavior` | -| AR1 | `Heading.test.tsx` display-type element tests | Levels with display and theme-added types | A visual type that changes the element fails. | `audit:Heading/a11y` | -| AR3 | `Heading.test.tsx` truncation title test; `HeadingAudit.a11y.chromium.spec.ts` | Truncated heading | A native `title` on a truncated heading fails both. | `audit:Heading/a11y` | -| AR1, AR2 | `HeadingAudit.a11y.chromium.spec.ts` reading Chromium's accessibility tree (`spec:AST-009` FR3) | Levels, equal and differing override, display types | A heading exposed with a role or level other than its element or `aria-level` requires fails the browser spec. | `audit:Heading/a11y` | +| Contract | Verification | Representative states | Mutation or failure expectation | Audit section | +| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------ | +| FR1, AR2 | `Heading.test.tsx` level and `accessibilityLevel` tests | Levels 1–6; differing and equal override | A wrong element, a missing `aria-level` for a differing override, or an `aria-level` added for an equal one fails. | `audit:Heading/a11y` | +| FR2 | `Heading.test.tsx` target, type, theme-added type, weight, and omitted-type tests; `extensibleAxes.test.ts`; `HeadingAudit.a11y.chromium.spec.ts` on the AuditMatrix story | Display types, theme-added type, weight | A lost `heading` class or `data-level`, `data-color`, `data-type`, or `data-weight` reflection, a reflected omitted type, or a theme-added type losing its level baseline fails. Display sizes out of order, or an explicit `bold` no heavier than the display default, fails the browser spec. Gap: the level scales and the level default weights have no paint check. | `audit:Heading/theming` | +| FR3 | Stable visual baseline `core-heading--level-1`; `Heading.stories.tsx`; `HeadingAudit.a11y.chromium.spec.ts` | Level 1 default; secondary color; `center` and `end` alignment | A changed level-1 scale, color, or display comes back changed for review; a `justify` that does not resolve to logical `center` or `end`, or heading text below its WCAG contrast threshold, fails the browser spec. Gap: `display` precedence, `textWrap`, cap-height trim, strikethrough, and the theme-added color baseline have no automated check. | `audit:Heading/behavior` | +| FR3 (reflow) | `Heading.test.tsx` long unbroken tokens; `TextReflow.a11y.chromium.spec.ts`; `scripts/text-overflow-wrap-anywhere.test.mjs` | A long unbroken token, untruncated and single-line truncated, at 320 CSS px; Text inside CommandPaletteEmpty and Banner | A token that does not wrap in an untruncated heading, a page that scrolls sideways at 320 px, single-line truncation that no longer clips on one line, Text inside CommandPaletteEmpty or Banner that loses the container's `anywhere` wrap or crosses an inline edge, or a Core style that sets `overflow-wrap: anywhere` without passing it to Text, fails. | `audit:Heading/a11y` | +| FR4, PR1 | `Heading.test.tsx` truncation-measurement tests; `useTruncation.test.tsx`; `HeadingAudit.a11y.chromium.spec.ts` | Tooltip on and off; content change; one and two lines | Measuring with the tooltip off, not measuring with it on, or a missed re-measure fails. A one-line heading without its ellipsis, a two-line clamp that does not hold two lines, or a clipped heading whose hover shows no full-text tooltip fails the browser spec. The `Heading.test.tsx` long-token tests pin the one-line `wordBreak` default and the `break-all` opt-in. Gap: the multi-line `wordBreak` default and the tooltip placement have no automated check. | `audit:Heading/behavior` | +| AR3 (tooltip mount), PR1 | `Heading.test.tsx` "the truncation tooltip mounts on the first interaction" case: no tooltip layer before any interaction, one on the first hover; the shared mount behavior is covered by the `Text.test.tsx` cases, since Text and Heading share `TruncationTooltip` | Truncated before and after the first hover, tap, or focus | A tooltip layer before the first interaction, a tooltip description at any time, or a first hover, tap or focus that does not open the Tooltip by its own rules, fails. Gap: no accessibility-tree check of the description (`spec:AST-009` FR3). | `audit:Heading/a11y` | +| FR5 | `Heading.test.tsx` ref, `id`, passthrough, `aria-level` precedence, styling-input, and line-clamp tests | Rerender; `id`; `data-testid`; caller `aria-level`; `className`, `xstyle`, and `style` | A detached ref, a lost `id` or test id, a derived `aria-level` that overrides the caller's, a `className` or `xstyle` that is dropped or merges before the component styles, or a caller `WebkitLineClamp` that replaces the clamp fails. | `audit:Heading/behavior` | +| AR1 | `Heading.test.tsx` display-type element tests | Levels with display and theme-added types | A visual type that changes the element fails. | `audit:Heading/a11y` | +| AR3 | `Heading.test.tsx` truncation title test; `HeadingAudit.a11y.chromium.spec.ts` | Truncated heading | A native `title` on a truncated heading fails both. | `audit:Heading/a11y` | +| AR1, AR2 | `HeadingAudit.a11y.chromium.spec.ts` reading Chromium's accessibility tree (`spec:AST-009` FR3) | Levels, equal and differing override, display types | A heading exposed with a role or level other than its element or `aria-level` requires fails the browser spec. | `audit:Heading/a11y` | ## Decision log diff --git a/docs/specs/components/Text/Text.spec.md b/docs/specs/components/Text/Text.spec.md index 950ce5f7d786f..b05a706669f60 100644 --- a/docs/specs/components/Text/Text.spec.md +++ b/docs/specs/components/Text/Text.spec.md @@ -212,7 +212,7 @@ record declares no anatomy-theming block rather than assign `heading` to Text. | FR2 | `Text.test.tsx` theme-added type and color tests; stable visual baseline `core-text--body` | Theme-added type and color; built-in color; body default | A theme-added type or color losing its reflection, a theme-added color losing its primary baseline, or a lost color override, fails; a changed body scale or color comes back changed for review. Gap: no test asserts a theme-added type's body baseline (the custom-type test checks only the class and `data-type`), and the built-in type tests assert presence only, so each type's size, line height, and weight, and the `size` and `weight` overrides in paint, have no automated check. Each type's default color and a built-in color's paint also have no automated check; the color tests assert `data-color` only. | `audit:Text/theming` | | FR3 | `Text.stories.tsx` | Display, cap-height trim, wrap, strikethrough, tabular numbers | Gap: the prop tests assert presence only, so `display` precedence, `justify`, and every text treatment have no automated check. | `audit:Text/behavior` | | FR3 (reflow) | `Text.test.tsx` long unbroken tokens; `TextReflow.a11y.chromium.spec.ts`; `scripts/text-overflow-wrap-anywhere.test.mjs` | A long unbroken token, inline and block, untruncated and single-line truncated, at 320 CSS px; Text inside CommandPaletteEmpty and Banner | A token that does not wrap in untruncated text, a page that scrolls sideways at 320 px, single-line truncation that no longer clips on one line, Text inside CommandPaletteEmpty or Banner that loses the container's `anywhere` wrap or crosses an inline edge, or a Core style that sets `overflow-wrap: anywhere` without passing it to Text, fails. | `audit:Text/a11y` | -| FR4, AR2, PR1 | `Text.test.tsx` native-title and truncation-measurement tests; `useTruncation.test.tsx` | Truncated with tooltip; tooltip off; content change | A native `title`, measuring with the tooltip off, not measuring with it on, or a missed re-measure fails. Gap: the ellipsis and line clamp, the `wordBreak` defaults, and the tooltip's appearance and placement have no automated check. | `audit:Text/a11y` | +| FR4, AR2, PR1 | `Text.test.tsx` native-title and truncation-measurement tests; `useTruncation.test.tsx` | Truncated with tooltip; tooltip off; content change | A native `title`, measuring with the tooltip off, not measuring with it on, or a missed re-measure fails. The `Text.test.tsx` long-token tests pin the one-line `wordBreak` default and the `break-all` opt-in. Gap: the ellipsis and line clamp, the multi-line `wordBreak` default, and the tooltip's appearance and placement have no automated check. | `audit:Text/a11y` | | AR2 (tooltip mount), PR1 | `Text.test.tsx` "the truncation tooltip mounts on the first interaction" cases: no tooltip layer or description before any interaction; the first hover mounts it and opens it after the hover delay, and neither that hover nor a later keyboard focus adds a description; a pointer that leaves first opens nothing; the tap that mounts it opens it and a tap outside closes it; a touch that becomes a scroll mounts nothing; keyboard focus inside the clamped element mounts it; a tap on a focusable child that focuses it first still opens the Tooltip, a tap on a text field only focuses it, before and after the Tooltip mounts, and a keyboard Tab to a text field mounts it; a caller's `preventDefault` does not stop the mount. Real-browser mount count on the `ManyTruncatedRows` story (500 rows: no tooltip layers at load) | Truncated before and after the first hover, tap, or focus | A tooltip layer before the first interaction, a tooltip description at any time, or a first hover, tap or focus that does not open the Tooltip by its own rules, fails. Gap: no accessibility-tree check of the description (`spec:AST-009` FR3). | `audit:Text/a11y` | | FR5 | `Text.test.tsx` ref and passthrough tests | Rerender; `data-testid` | A detached ref or a lost test id fails. Gap: no test covers other DOM passthrough, the styling-input merge order, or the line clamp after `style`. | `audit:Text/behavior` | From 3b54759033bdd7154bcdddc1287346d56f1379b4 Mon Sep 17 00:00:00 2001 From: Cindy Zhang Date: Fri, 4 Dec 2026 02:13:37 -0800 Subject: [PATCH 7/7] Make the word-break comment hold for every language Korean, Chinese and Japanese text still breaks between syllables or characters, so the comment says lines break where a multi-line clamp breaks them. --- packages/core/src/Heading/Heading.tsx | 2 +- packages/core/src/Text/Text.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/Heading/Heading.tsx b/packages/core/src/Heading/Heading.tsx index 84c21c5877ec8..e26fd4ae91e74 100644 --- a/packages/core/src/Heading/Heading.tsx +++ b/packages/core/src/Heading/Heading.tsx @@ -268,7 +268,7 @@ export function Heading({ : {}; // A single-line clamp does not wrap. If a caller restores wrapping, - // lines break between words, as in a multi-line clamp. + // lines break where a multi-line clamp breaks them. const resolvedWordBreak = wordBreak ?? 'break-word'; // Resolve display - force block when maxLines > 0 or hasCapsize diff --git a/packages/core/src/Text/Text.tsx b/packages/core/src/Text/Text.tsx index 3aacc7012f5ad..c242a939e1b44 100644 --- a/packages/core/src/Text/Text.tsx +++ b/packages/core/src/Text/Text.tsx @@ -259,7 +259,7 @@ export function Text({ const styleColor = resolveStyleColor(resolvedColor); // A single-line clamp does not wrap. If a caller restores wrapping, - // lines break between words, as in a multi-line clamp. + // lines break where a multi-line clamp breaks them. const resolvedWordBreak = wordBreak ?? 'break-word'; // Resolve display - force block when maxLines > 0 or hasCapsize