Skip to content

fix(core): names built from a node's text keep inline markup's words whole - #13710

Merged
cixzhang merged 3 commits into
mainfrom
lane2/getnodetext-inline-join
Nov 24, 2026
Merged

cixzhang merged 3 commits into
mainfrom
lane2/getnodetext-inline-join

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

User impact

Several names that Astryx builds from a node's text split words at inline markup, so a screen reader heard text the page does not show:

  • a Table column-resize handle whose header is H<sub>2</sub>O level was named "Resize column H 2 O level";
  • a List reorder announcement for a row labelled H<sub>2</sub>O said "H 2 O, position 2 of 3…";
  • a toast whose plain-text body arrives in parts, such as {42}% uploaded, was announced as "42 % uploaded".

They now read as the text renders: "H2O level", "H2O", "42% uploaded". Tooltip descriptions also take their text from this function once the tooltip mounts its layer at first show (a follow-up change), so un<b>like</b>ly will be described as "unlikely", not "un like ly".

Problem and solution fit

  1. Why are the names wrong? getNodeText joined every string and element child with a space.
  2. Why does that harm the task? Inline elements (b, strong, sub, em, …) run into the text beside them on the page, so the spoken name splits words the reader sees as one.
  3. Why does it matter? An accessible name must match the words on screen (WCAG 2.5.3 Label in Name), and a split word is read as separate words.

The fix joins text as it renders. Inline elements join the text beside them with no separator, while a block element, a <br> or a component stands apart with a single space. A component counts as a block because its display is unknown here, which keeps today's spacing around components.

Expected behavior and authority

getNodeText's own contract is "the plain text a node renders". Its callers use it for spoken names: the Table column-resize handle names (Table AR1: an "accessible name naming its column"), List reorder names, and Toast announcements.

Smallest restoration

  • utils/getNodeText.ts: one walk that collects text pieces and joins them by display. A fragment is transparent, and the block host elements are listed.
  • No caller changes.

Evidence

  • Reproduction before the change: on main's getNodeText.ts, 6 tests fail, including:
    • "un like ly", "Total 3" and "Saved now" in the unit test;
    • "Resize column H 2 O level";
    • "H 2 O, position 2 of 3…";
    • "42 % uploaded".
  • Result after the change: the 4 test files pass, 233/233.
  • Representative unchanged path: the Toast, List, Table and utils ui suites pass, apart from locale tests the test box's Node cannot run without full ICU (calendar, date and time parsing, locale sort), which are unrelated to this change.
  • Regression tests: getNodeText.test.ts, useTableColumnResize.test.tsx, ListReorder.test.tsx, ToastViewport.test.tsx.

Scope

Components: utils (getNodeText), Table, List, Toast

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • vitest run --project ui on the 4 test files: 233/233. With main's getNodeText.ts: 6 failed.
  • vitest run --project ui packages/core/src/Toast packages/core/src/List packages/core/src/Table packages/core/src/utils: only small-ICU locale failures, which are unrelated.
  • Core tsc --noEmit, ESLint and Prettier are clean, and check:changesets is valid.

@vercel

vercel Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 24, 2026 4:27am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 24, 2026
@astracat-bot

astracat-bot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 24, 2026, 5:11 AM UTC

@cixzhang cixzhang added the lane:2 Astryx fix-loop lane 2 owns this label Nov 24, 2026
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec d4ff82c

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · d663344

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
Table 127.9 kB (0) · 21.3 kB CSS (0) — ✗ · ✓ · —
TableBody 6.8 kB (0) · 3.3 kB CSS (0) — ✗ · ✓ · ✗
TableCell 109.7 kB (0) · 20.3 kB CSS (0) — ✗ · ✓ · ✓
8 more components
Component Size LoC Visual · A11y · RTL
TableFooter 3.6 kB (0) · 3.3 kB CSS (0) — ✗ · ✓ · ✗
TableHeader 3.6 kB (0) · 3.3 kB CSS (0) — ✗ · ✓ · ✗
TableHeaderCell 109.6 kB (0) · 20.1 kB CSS (0) — ✗ · ✓ · ✓
TableRow 7.3 kB (0) · 4.1 kB CSS (0) — ✗ · ✓ · ✗
TableSelectionToolbar 79.1 kB (0) · 14.6 kB CSS (0) — ✗ · ✓ · ✓
List 19.7 kB (0) · 810 B CSS (0) — ✓ · ✓ · —
ListItem 83.1 kB (0) · 12.6 kB CSS (0) — ✓ · ✓ · ✓
Toast · Storybook 108.5 kB (0) · 11.5 kB CSS (0) 1,863 (0) ✓ · ✓ · ✓
Visual changes: 2 snapshots in 1 component

A change is a question for the reviewer, not a failure.

Component · story Before After Diff
Table · Default (neutral, dark) · inheritance unknown: not found in the 6 newest reports of other pull requests before frame after frame diff frame
Table · Default (neutral, light) · inheritance unknown: not found in the 6 newest reports of other pull requests before frame after frame diff frame

Inheritance checked against the 6 newest reports of other pull requests.

Package size: @astryxdesign/core 8.02 MB packed (+1.1 kB); no new dependencies.

Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-rtl for RTL.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI has not run on this head yet.

getNodeText now joins inline markup the way it renders, and each of the three spoken names it feeds has a regression test that fails with the old function. Two optional cleanups remain. First, drop "a tooltip's description" from the @position header in getNodeText.ts until the tooltip change that uses it lands. Second, in the description, quote Table AR1 as "accessible name naming its column", since "the header's visible text" is the existing AR1 test's title.

Claims and files checked

Review mode: full; reason: no-earlier-review

Claims:

  • Names built from a node's text read as the text renders, and inline markup no longer splits words: verified (getNodeText.ts:97-125, getNodeText.test.ts:20-33).
  • The before and after examples (un like ly to unlikely, H 2 O to H2O, 42 % to 42%): verified against the old and new functions on those inputs.
  • The fix covers the column-resize handle, the List reorder announcement and plain-text toasts: verified (callers at useTableColumnResize.tsx:805, ListReorderHandle.tsx:249 and :416, ToastViewport.tsx:595; tests at useTableColumnResize.test.tsx:599, ListReorder.test.tsx:480, ToastViewport.test.tsx:3220).
  • A block element, a line break and a component still stand apart with a space: verified (getNodeText.test.ts:35-52, getNodeText.ts:90-91).
  • The old function joined every string and element child with a space: verified (the base's array branch).
  • A component counts as a block, which keeps today's spacing around components: verified (getNodeText.ts:88-91).
  • The function's own contract is the plain text a node renders: partly accurate, since the old doc comment also said "joined with spaces" and this change rewrites that sentence (getNodeText.ts:116-122).
  • The handle's name rests on Table AR1's "header's visible text": partly accurate, since AR1 says the name names its column and the quoted words are the title of the existing AR1 test (useTableColumnResize.test.tsx:577).
  • One walk collects text pieces, a fragment is transparent, and the block elements are listed: verified (getNodeText.ts:19-62, :70-95).
  • No caller changes: verified (only the utility, its tests, three caller tests and the changeset change).
  • Six tests fail with the old function: verified (three unit tests and the three caller tests).
  • The four test files pass, the wider suites pass apart from locale tests, and typecheck, lint, formatting and the changeset check are clean: pending CI, which has not run on this head.
  • Tooltip descriptions adopt the function in a later change: stated as future work, and no tooltip calls it at this head.
  • No new public API and no internal context: verified (no package entry exports getNodeText).

Files:

  • .changeset/getnodetext-inline-markup-joins.md: clear
  • packages/core/src/utils/getNodeText.ts: one non-blocking note (header line 9)
  • packages/core/src/utils/getNodeText.test.ts: clear
  • packages/core/src/List/__tests__/ListReorder.test.tsx: clear
  • packages/core/src/Table/plugins/columnResize/useTableColumnResize.test.tsx: clear
  • packages/core/src/Toast/ToastViewport.test.tsx: clear

Automated review (maintainer link)

* @position Shared utility; consumed where a rendered node also needs a
* spoken name (Toast announcements, Table column-resize handle names)
* spoken name (Toast announcements, Table column-resize handle names, List
* reorder names, a tooltip's description)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: no tooltip calls getNodeText at this head. The callers are Table column resize, List reorder and Toast. Drop "a tooltip's description" until the change that adopts it lands, so the header lists only real consumers.

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec d663344

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. getNodeText now joins inline markup the way it renders, and each of the three spoken names it feeds has a regression test that fails with the old function and passes in CI on this head. Two optional follow-ups remain:

  • Drop "a tooltip's description" from the @position header in getNodeText.ts until the tooltip change that uses it lands.
  • A block nested inside an inline element still loses its space (['x', <span><div>A</div></span>, 'y'] reads "xAy"), so carry the children's block edges up to the element's piece, or narrow the JSDoc to blocks beside the text.
Claims and files checked

Review mode: same-head; reason: none

Claims:

  • Inline markup split words in three spoken names (the column-resize handle, the List reorder announcement, a plain-text toast body in parts): verified against the old function on those inputs.
  • They now read "H2O level", "H2O" and "42% uploaded": verified (getNodeText.ts:97-125; tests at useTableColumnResize.test.tsx:599, ListReorder.test.tsx:480 and ToastViewport.test.tsx:3220, green in CI).
  • Tooltip descriptions adopt the function in a later change: stated as future work, and no tooltip calls it on this head.
  • The old function joined every string and element child with a space: verified (the old array branch).
  • A spoken name should match the words on screen, and a split word reads as separate words: accurate as background; the governing clauses are the component records.
  • Inline elements join with no separator, while a block element, a <br> or a component stands apart with one space: verified beside the text (getNodeText.ts:88-114, getNodeText.test.ts:35-52); a block nested inside an inline element does not (the follow-up above).
  • A component counts as a block, which keeps today's spacing around components: verified (getNodeText.ts:88-91).
  • The function's contract is the plain text a node renders: verified, the opening words of both the old and the new doc comment.
  • The callers use it for spoken names, with the Table handle named after its column: verified (the column-resize record's wording matches; callers at useTableColumnResize.tsx:805, ListReorderHandle.tsx:249 and :416, ToastViewport.tsx:595).
  • One walk collects text pieces, a fragment is transparent, and the block elements are listed: verified (getNodeText.ts:19-95).
  • No caller changes: verified (only the utility, its tests, three caller tests and the changeset change).
  • Six tests fail with the old function: verified (three unit tests and the three caller tests).
  • The four test files pass, 233 of 233: verified in CI on this head (4, 66, 51 and 112 tests).
  • The Toast, List, Table and utils suites pass: verified in CI, where every ui test shard passes.
  • Typecheck, ESLint, Prettier and the changeset check are clean: verified in CI (typecheck and lint pass; every changed file is formatted; the changeset check is valid).
  • One defect, no new public API, default or interaction model, and no internal context: verified (no package entry exports getNodeText; CI's API diff lists no change; no internal reference in the added lines).
  • Changeset: names built from a node's text read as the text renders, so "unlikely", "H2O" and "42%" replace "un like ly", "H 2 O" and "42 %": verified (getNodeText.test.ts:20-33).
  • Changeset: this covers the column-resize handle, the List reorder announcement and a plain-text toast body in parts: verified (the three callers and their tests).
  • Changeset: a block element, a line break and a component still stand apart with a space: verified beside the text; not for a block nested inside an inline element (the follow-up above).

Files:

  • .changeset/getnodetext-inline-markup-joins.md: clear
  • packages/core/src/utils/getNodeText.ts: two non-blocking notes (header line 9; lines 90-92)
  • packages/core/src/utils/getNodeText.test.ts: clear
  • packages/core/src/List/__tests__/ListReorder.test.tsx: clear
  • packages/core/src/Table/plugins/columnResize/useTableColumnResize.test.tsx: clear
  • packages/core/src/Toast/ToastViewport.test.tsx: clear

Automated review (maintainer link)

// block's does.
const isBlock =
typeof node.type !== 'string' || BLOCK_ELEMENTS.has(node.type);
return [{text: joinPieces(piecesOf(children)), isBlock}];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking (missed in the earlier review): this piece carries only the element's own display, so a block nested inside an inline element loses its edges. ['x', <span><div>A</div></span>, 'y'] reads "xAy" (the old function read "x A y"), while the JSDoc says a block element stands apart with a space. Carry the first and last child pieces' block edges up to this piece, or narrow the JSDoc to blocks beside the text.

@cixzhang
cixzhang marked this pull request as ready for review November 24, 2026 04:41
@cixzhang cixzhang added the ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) label Nov 24, 2026
@cixzhang
cixzhang marked this pull request as draft November 24, 2026 04:46
@cixzhang
cixzhang marked this pull request as ready for review November 24, 2026 04:47
@cixzhang
cixzhang merged commit 5bf1e0a into main Nov 24, 2026
195 of 245 checks passed
@github-actions
github-actions Bot deleted the lane2/getnodetext-inline-join branch November 24, 2026 06:07

This branch was successfully deployed

1 active deployment
Preview — d663344f Deployed Nov 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) CLA Signed This label is managed by the Meta Open Source bot. lane:2 Astryx fix-loop lane 2 owns this

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant