Repository navigation
fix(utils): getNodeText keeps a block apart from the text beside it when an inline element holds it - #13728
Conversation
…hen an inline element holds it
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec f6a32a8 |
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC |
|---|---|---|
| SegmentedControl | 105.3 kB (+131 B) · 7.6 kB CSS (0) | — |
| lab/ChatEmojiPicker | 131.6 kB (+123 B) · 773 B CSS (0) | — |
| MoreMenu | 136.6 kB (+111 B) · 19.9 kB CSS (0) | — |
120 more components
| Component | Size | LoC |
|---|---|---|
| lab/MediaCaptionsButton | 232.5 kB (+111 B) · 1.5 kB CSS (0) | — |
| lab/MediaTimeSlider | 232.5 kB (+111 B) · 1.5 kB CSS (0) | — |
| lab/MediaFullscreenButton | 232.5 kB (+110 B) · 1.5 kB CSS (0) | — |
| lab/MediaPlaybackRate | 232.5 kB (+110 B) · 1.5 kB CSS (0) | — |
| lab/MediaPlayButton | 232.5 kB (+110 B) · 1.5 kB CSS (0) | — |
| lab/MediaSeekButton | 232.5 kB (+110 B) · 1.5 kB CSS (0) | — |
| lab/MediaTime | 232.5 kB (+110 B) · 1.5 kB CSS (0) | — |
| lab/MediaVolume | 232.5 kB (+110 B) · 1.5 kB CSS (0) | — |
| CheckboxInput | 73.3 kB (+108 B) · 10.9 kB CSS (0) | — |
| lab/AudioPlayer | 242.3 kB (+107 B) · 1.8 kB CSS (0) | — |
| charts/ChartTooltip | 230.9 kB (+106 B) · 451 B CSS (0) | — |
| TextInput | 103.6 kB (+106 B) · 12.9 kB CSS (0) | — |
| Tokenizer | 116.4 kB (+106 B) · 22.0 kB CSS (0) | — |
| DropdownMenu | 136.3 kB (+105 B) · 19.9 kB CSS (0) | — |
| Slider | 119.0 kB (+104 B) · 9.6 kB CSS (0) | — |
| ContextMenu | 109.8 kB (+103 B) · 19.7 kB CSS (0) | — |
| MobileNavToggle | 71.5 kB (+103 B) · 11.8 kB CSS (0) | — |
| PowerSearch | 323.7 kB (+103 B) · 27.4 kB CSS (0) | — |
| Table | 129.2 kB (+103 B) · 21.3 kB CSS (0) | — |
| TopNavMegaMenu | 84.4 kB (+103 B) · 13.2 kB CSS (0) | — |
| lab/ChatReactionBar | 132.8 kB (+103 B) · 1.1 kB CSS (0) | — |
| lab/Comments | 394.0 kB (+103 B) · 2.5 kB CSS (0) | — |
| Lightbox | 153.6 kB (+102 B) · 12.4 kB CSS (0) | — |
| TopNav | 73.2 kB (+102 B) · 12.1 kB CSS (0) | — |
| lab/ListInput | 99.5 kB (+102 B) · 922 B CSS (0) | — |
| lab/TabBarMoreList | 107.4 kB (+102 B) · 1.8 kB CSS (0) | — |
| lab/TourStep | 99.2 kB (+102 B) · 691 B CSS (0) | — |
| Carousel | 80.2 kB (+101 B) · 12.2 kB CSS (0) | — |
| TabMenu | 87.3 kB (+101 B) · 12.5 kB CSS (0) | — |
| lab/SelectableCardGroup | 73.7 kB (+101 B) · 162 B CSS (0) | — |
| ToggleButton | 97.2 kB (+100 B) · 11.3 kB CSS (0) | — |
| richtext/RichTextEditorToolbar | 319.7 kB (+100 B) · 454 B CSS (0) | — |
| charts/Chart | 254.4 kB (+98 B) · 516 B CSS (0) | — |
| ComplexSelector | 86.5 kB (+98 B) · 13.3 kB CSS (0) | — |
| Markdown | 213.8 kB (+98 B) · 23.6 kB CSS (0) | — |
| RadioList | 64.8 kB (+98 B) · 8.0 kB CSS (0) | — |
| ChatLayout | 93.5 kB (+97 B) · 11.7 kB CSS (0) | — |
| DateInput | 212.1 kB (+97 B) · 19.0 kB CSS (0) | — |
| Switch | 113.7 kB (+97 B) · 10.8 kB CSS (0) | — |
| TextArea | 97.1 kB (+97 B) · 10.3 kB CSS (0) | — |
| TimeInput | 184.3 kB (+97 B) · 17.9 kB CSS (0) | — |
| lab/VideoPlayer | 239.8 kB (+97 B) · 2.1 kB CSS (0) | — |
| CheckboxList | 77.4 kB (+96 B) · 8.5 kB CSS (0) | — |
| MultiSelector | 112.2 kB (+96 B) · 19.0 kB CSS (0) | — |
| SideNav | 118.0 kB (+96 B) · 12.6 kB CSS (0) | — |
| richtext/RichTextEditor | 313.2 kB (+96 B) · 2.7 kB CSS (0) | — |
| BreadcrumbItem | 106.0 kB (+95 B) · 14.1 kB CSS (0) | — |
| DateRangeInput | 109.2 kB (+95 B) · 14.3 kB CSS (0) | — |
| FieldLabel | 58.8 kB (+95 B) · 6.5 kB CSS (0) | — |
| Toast | 109.7 kB (+95 B) · 11.5 kB CSS (0) | — |
| InfoTip | 53.4 kB (+94 B) · 6.0 kB CSS (0) | — |
| AppShell | 93.9 kB (+93 B) · 15.0 kB CSS (0) | — |
| DateTimeInput | 236.3 kB (+93 B) · 20.7 kB CSS (0) | — |
| Selector | 124.5 kB (+93 B) · 19.8 kB CSS (0) | — |
| Avatar | 48.3 kB (+92 B) · 6.3 kB CSS (0) | — |
| AvatarGroupOverflow | 54.4 kB (+92 B) · 6.3 kB CSS (0) | — |
| ListItem | 84.0 kB (+92 B) · 12.8 kB CSS (0) | — |
| Pagination | 157.4 kB (+92 B) · 20.2 kB CSS (0) | — |
| TopNavMenu | 90.2 kB (+92 B) · 12.6 kB CSS (0) | — |
| Typeahead | 98.2 kB (+92 B) · 14.5 kB CSS (0) | — |
| lab/CommentComposer | 190.1 kB (+92 B) · 1.9 kB CSS (0) | — |
| lab/CommentThread | 387.1 kB (+92 B) · 2.4 kB CSS (0) | — |
| TableCell | 110.9 kB (+91 B) · 20.3 kB CSS (0) | — |
| TopNavHeading | 90.8 kB (+91 B) · 12.6 kB CSS (0) | — |
| lab/TransferList | 142.3 kB (+91 B) · 1.2 kB CSS (0) | — |
| ChatComposer | 93.5 kB (+90 B) · 13.6 kB CSS (0) | — |
| ChatComposerInput | 90.6 kB (+90 B) · 12.6 kB CSS (0) | — |
| ChatComposerTokenElement | 90.6 kB (+90 B) · 12.6 kB CSS (0) | — |
| Field | 63.3 kB (+90 B) · 8.0 kB CSS (0) | — |
| lab/TransferListSelector | 154.5 kB (+90 B) · 1.4 kB CSS (0) | — |
| RadioListItem | 81.1 kB (+89 B) · 11.5 kB CSS (0) | — |
| StatusDot | 36.1 kB (+89 B) · 6.0 kB CSS (0) | — |
| richtext/RichTextView | 289.9 kB (+89 B) · 2.4 kB CSS (0) | — |
| BaseTypeahead | 86.6 kB (+88 B) · 12.2 kB CSS (0) | — |
| CheckboxListItem | 84.8 kB (+88 B) · 12.8 kB CSS (0) | — |
| Thumbnail | 74.2 kB (+88 B) · 12.8 kB CSS (0) | — |
| lab/EmojiPicker | 123.3 kB (+88 B) · 751 B CSS (0) | — |
| lab/Schedule | 121.4 kB (+88 B) · 3.9 kB CSS (0) | — |
| MobileNav | 82.1 kB (+87 B) · 11.8 kB CSS (0) | — |
| NumberInput | 108.6 kB (+87 B) · 13.1 kB CSS (0) | — |
| AlertDialog | 136.5 kB (+86 B) · 16.3 kB CSS (0) | — |
| Link | 59.7 kB (+86 B) · 7.8 kB CSS (0) | — |
| SideNavHeading | 91.1 kB (+85 B) · 12.6 kB CSS (0) | — |
| Stepper | 71.4 kB (+85 B) · 11.3 kB CSS (0) | — |
| Popover | 108.1 kB (+84 B) · 15.7 kB CSS (0) | — |
| lab/CommentPin | 63.2 kB (+84 B) · 1.2 kB CSS (0) | — |
| AvatarGroup | 51.1 kB (+83 B) · 6.4 kB CSS (0) | — |
| InputGroup | 65.4 kB (+83 B) · 9.2 kB CSS (0) | — |
| lab/DialogHeroHeader | 94.4 kB (+83 B) · 372 B CSS (0) | — |
| Calendar | 80.9 kB (+82 B) · 11.8 kB CSS (0) | — |
| SideNavItem | 85.2 kB (+82 B) · 12.5 kB CSS (0) | — |
| TableHeaderCell | 110.8 kB (+82 B) · 20.1 kB CSS (0) | — |
| lab/DiffViewer | 98.8 kB (+81 B) · 2.3 kB CSS (0) | — |
| Banner | 71.7 kB (+80 B) · 11.7 kB CSS (0) | — |
| ChatDictationButton | 70.2 kB (+80 B) · 11.3 kB CSS (0) | — |
| CodeBlock | 85.8 kB (+80 B) · 12.9 kB CSS (0) | — |
| FileInput | 79.8 kB (+80 B) · 12.9 kB CSS (0) | — |
| TableSelectionToolbar | 80.2 kB (+80 B) · 14.6 kB CSS (0) | — |
| ChatLayoutScrollButton | 70.2 kB (+79 B) · 11.4 kB CSS (0) | — |
| Tooltip | 34.4 kB (+79 B) · 5.1 kB CSS (0) | — |
| ChatSendButton | 70.1 kB (+78 B) · 11.2 kB CSS (0) | — |
| DialogHeader | 72.9 kB (+78 B) · 12.9 kB CSS (0) | — |
| Button | 69.6 kB (+77 B) · 11.2 kB CSS (0) | — |
| DrawerHeader | 73.1 kB (+77 B) · 14.3 kB CSS (0) | — |
| SideNavCollapseButton | 70.5 kB (+76 B) · 11.3 kB CSS (0) | — |
| IconButton | 69.7 kB (+74 B) · 11.2 kB CSS (0) | — |
| ChatToolCalls | 33.6 kB (+1 B) · 9.2 kB CSS (0) | — |
| Heading | 12.9 kB (+1 B) · 6.1 kB CSS (0) | — |
| Spinner | 25.7 kB (+1 B) · 6.9 kB CSS (0) | — |
| charts/ChartLegend | 42.6 kB (0) · 224 B CSS (0) | — |
| ChatMessageList | 29.1 kB (0) · 7.8 kB CSS (0) | — |
| CommandPaletteInput | 34.7 kB (0) · 8.3 kB CSS (0) | — |
| ProgressBar | 12.6 kB (0) · 7.0 kB CSS (0) | — |
| Text | 12.0 kB (0) · 6.1 kB CSS (0) | — |
| Timer | 14.5 kB (0) · 6.7 kB CSS (0) | — |
| Timestamp | 28.4 kB (0) · 11.5 kB CSS (0) | — |
| lab/LineClamp | 14.6 kB (0) · 168 B CSS (0) | — |
| CommandPalette | 84.7 kB (−1 B) · 13.8 kB CSS (0) | — |
| DropdownMenuSubMenu | 82.8 kB (−1 B) · 11.4 kB CSS (0) | — |
| NavHeadingMenuItem | 19.9 kB (−2 B) · 7.0 kB CSS (0) | — |
Package size: @astryxdesign/core 8.03 MB packed (+436 B); no new dependencies.
Not run on this PR: add ci:run-visual for Visual, ci:run-rtl for RTL.
Generated by PR Enrichment workflow | View full report
|
/approve-spec 4c63d18 |
There was a problem hiding this comment.
Changes requested: the fix itself holds up, but the release note promises a change that cannot happen, and the size report the import-boundaries record asks for is missing.
- The changeset lists a Toast announcement among the names this fix changes, but the viewport builds an announcement with this helper only when the toast body is plain text (a string, a number, or an array of them) and reads any other body from the DOM after the toast commits, so no Toast body can carry an inline element around a block into it: drop "a Toast announcement" from the changeset and from the description's User impact, keeping the Table resize handle, the List reorder announcement and the tooltip description.
- The import-boundaries record asks a pull request that grows a shared module to report the first-load gzip delta on the four reference pages, and this one grows a helper that four component folders import, so please add the base-against-head numbers for the docs, form, menu and table pages (
pnpm check:component-import-boundaries --base-ref <base>prints them per entry).
Non-blocking: the sentence added to the exported JSDoc leaves one 106-character line inside a block wrapped at about 75, so the paragraph is worth re-wrapping.
The behaviour is right: running the base and head copies of the helper over 34 inputs, all five new assertions hold on this head, the first three fail on the base, the 18 cases already in the suite are unchanged, and the join can only add a space, never remove one.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Release note, the four names it says this fix changes: true for the Table column-resize handle, the List reorder announcement and the tooltip description, each of which takes an arbitrary node; false for the Toast announcement (verified at the viewport's announce path and the toast's own DOM-reading path).
- Release note example,
['x', <span><div>A</div></span>, 'y']reads "x A y" where it read "xAy": verified against both trees. - Description, the new case fails on the base with "xAy": verified.
- Description, results after the change ("x A y", "Total12 items left", "Saved now", "a B c", and inline-only text still joining): verified, all five assertions.
- Description, the changeset check passes: verified by running it at this head.
- Description, the full unit run, the TypeScript check, ESLint and the comment-provenance baseline: not verified here, because this review could not install dependencies; that is a limit of the review, not a finding.
- Table column-resize record, the boundary keeps an accessible name naming its column: preserved.
- Tooltip record, the description before first mount is a hidden copy of the trigger's text: preserved.
- Toast record, the viewport announces using the toast's text content: unchanged by this pull request.
- Import-boundaries record, a pull request that grows a shared module reports the first-load gzip delta on the four reference pages: missing.
- Accessibility spec-test record, WCAG 2.2 A and AA as the conformance baseline: consistent, and a baseline does not settle which conforming string ships.
- Knowledge-contracts record, source comments in simplified English: one re-wrap suggestion.
.changeset/getnodetext-block-inside-inline.md: finding, the Toast claim.packages/core/src/utils/getNodeText.ts: clear, apart from the line-wrap note.packages/core/src/utils/getNodeText.test.ts: clear, and its five assertions match the helper's behaviour at this head.- Read for consistency, unchanged: the four call sites in the Table column-resize plugin, the List reorder handle and row name, the Toast viewport, and the tooltip description copy.
…-wrap its doc comment
|
/approve-spec 3f2528c |
There was a problem hiding this comment.
Approved: the fix holds, and CI has passed on this head.
getNodeText now keeps a block apart from the words beside it when an inline element holds the block, and the release note and description match what the code does. One non-blocking wording suggestion for the edgesOf comment stays open inline.
Claims and files checked
Review mode: same-head; reason: none
- Changed rules (1): an owner's change request stays open until that owner clears it, including the maintainer-account dismissal path: checked this pull request's GitHub reviews; no owner change request, no finding.
- Title, the helper keeps a block apart from the text beside it when an inline element holds it: verified.
- Release note, the three spoken names it lists (Table column resize handle, List reorder announcement, tooltip description): verified, each call site passes arbitrary children to the helper.
- Release note example, the span-wrapped block between
xandyreads "x A y" where it read "xAy": verified on both trees. - Description, Toast passes only a plain-text body, so Toast announcements are unchanged: verified at the viewport's plain-text check.
- Description, the space went missing because a block inside an inline element did not pass its edges up, since #13710: verified against the base helper and its history.
- Description, the helper's contract of reading text "as it reads on the page": verified in its doc comment.
- Description, the smallest restoration (edges from the first and last text; inline-only text still joins, "unlikely"): verified.
- Description, the new case fails on the base with "xAy": verified.
- Description, results after the change ("x A y", "Total12 items left", "Saved now", "a B c", inline-only text joining): verified, all five, and the new test passes in CI.
- Description, the existing helper cases and the Tooltip, Toast, Table column resize, List, Text and Button suites still pass: verified, the existing cases return the same strings and CI's UI tests pass on this head; the subset's exact count was not rerun.
- Description, first-load size on the four reference pages under 0.3 KB gzip, and the entry-boundary check at +0.0 to +0.1 KB per entry with no new boundary hit: the per-page report is present, and CI's boundary check on this head prints the same per-entry range and passes; the page builds were not rerun.
- Description, no new public API: verified; the helper is not exported from the package or its internal entries.
- Description, type check, ESLint, comment-provenance baseline and changeset check pass: verified, CI's typecheck and lint jobs pass on this head.
- Description, no internal context in public text: verified.
.changeset/getnodetext-block-inside-inline.md: clear.packages/core/src/utils/getNodeText.ts: clear, apart from the non-blockingedgesOfcomment wording.packages/core/src/utils/getNodeText.test.ts: clear.
| /** | ||
| * The block edges an inline element takes from its children: a block before | ||
| * its first text starts it, and a block after its last text ends it. | ||
| */ |
There was a problem hiding this comment.
Non-blocking: this sentence runs to 27 words, over the 25-word limit the repository's source-comment rule sets for a description. Three short sentences keep the rule, for example:
/**
* An inline element takes its block edges from its children. A block before
* its first text starts it. A block after its last text ends it.
*/
User impact
Some spoken names are read from rendered children with
getNodeText: a Table column's resize handle, a List reorder announcement, and a tooltip's description before the tooltip first shows. (A Toast passes only a plain-text body to it, so Toast announcements are unchanged.) When an inline element holds a block (for example<span><div>A</div></span>between two words), the name runs the words together:['x', <span><div>A</div></span>, 'y']reads "xAy", but the page shows x, A and y on separate lines. A screen-reader user hears a word that is not on the screen, and a speech-input user cannot say the name they see (WCAG 2.5.3).Problem and solution fit
getNodeTextputs a space around a block element,<br>or component, and joins inline elements with no separator. A block nested inside an inline element does not pass its block edges up, so the inline element's text joins its neighbours.spec:AST-020FR1, WCAG 2.5.3).The fix carries a child's leading and trailing block edges up to the inline element that holds it, so the space goes where the page breaks the line.
Expected behavior and authority
getNodeText's contract: "the plain text a node renders … as it reads on the page".spec:AST-020FR1 and WCAG 2.5.3.Smallest restoration
packages/core/src/utils/getNodeText.ts: a text piece records whether a block starts it and whether one ends it, instead of a single block flag. A block element or component starts and ends its piece. An inline element takes its edges from its children: a block before its first text, or after its last text. Joining puts a space before a piece that starts with a block and after one that ends with one, as before. Inline-only text joins as before (un<b>like</b>lyreads "unlikely").Evidence
Received: "xAy".x A y,Total12 items left,Saved now(an inline element that holds only a<br>), anda B c(a block in the middle of an inline element). Inline-only text still joins.pnpm size:pages --base origin/main, minified / gzip bytes), all under the 0.3 KB gzip limit:The entry-boundary check reports +0.0 to +0.1 KB gzip per entry and no new boundary hit.
getNodeText.test.ts, "keeps a block apart from the text beside it when an inline element holds it".Scope
Components: utils (getNodeText)
Testing
vitest run --project ui packages/core/src/utils/getNodeText.test.ts packages/core/src/Tooltip packages/core/src/Toast packages/core/src/Table/useTableColumnResize.test.tsx packages/core/src/List packages/core/src/Text packages/core/src/Button: 1163 passed. The new case fails on the base.tsc --noEmit -p packages/core: clean. ESLint clean. Comment-provenance baseline up to date.check:changesetspasses.