Repository navigation
fix(core): names built from a node's text keep inline markup's words whole - #13710
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec d4ff82c |
PR Analysis Report🔎 Preview ·
|
| 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.
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
There was a problem hiding this comment.
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:249and:416,ToastViewport.tsx:595; tests atuseTableColumnResize.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: clearpackages/core/src/utils/getNodeText.ts: one non-blocking note (header line 9)packages/core/src/utils/getNodeText.test.ts: clearpackages/core/src/List/__tests__/ListReorder.test.tsx: clearpackages/core/src/Table/plugins/columnResize/useTableColumnResize.test.tsx: clearpackages/core/src/Toast/ToastViewport.test.tsx: clear
| * @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) |
There was a problem hiding this comment.
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.
|
/approve-spec d663344 |
There was a problem hiding this comment.
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
@positionheader ingetNodeText.tsuntil 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 atuseTableColumnResize.test.tsx:599,ListReorder.test.tsx:480andToastViewport.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:249and: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: clearpackages/core/src/utils/getNodeText.ts: two non-blocking notes (header line 9; lines 90-92)packages/core/src/utils/getNodeText.test.ts: clearpackages/core/src/List/__tests__/ListReorder.test.tsx: clearpackages/core/src/Table/plugins/columnResize/useTableColumnResize.test.tsx: clearpackages/core/src/Toast/ToastViewport.test.tsx: clear
| // block's does. | ||
| const isBlock = | ||
| typeof node.type !== 'string' || BLOCK_ELEMENTS.has(node.type); | ||
| return [{text: joinPieces(piecesOf(children)), isBlock}]; |
There was a problem hiding this comment.
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.






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:
H<sub>2</sub>O levelwas named "Resize column H 2 O level";H<sub>2</sub>Osaid "H 2 O, position 2 of 3…";{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>lywill be described as "unlikely", not "un like ly".Problem and solution fit
getNodeTextjoined every string and element child with a space.b,strong,sub,em, …) run into the text beside them on the page, so the spoken name splits words the reader sees as one.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.Evidence
getNodeText.ts, 6 tests fail, including:getNodeText.test.ts,useTableColumnResize.test.tsx,ListReorder.test.tsx,ToastViewport.test.tsx.Scope
Components: utils (getNodeText), Table, List, Toast
Testing
vitest run --project uion the 4 test files: 233/233. With main'sgetNodeText.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.tsc --noEmit, ESLint and Prettier are clean, andcheck:changesetsis valid.