Repository navigation
perf(EmptyState): look for a live-region ancestor before the visibility read - #13747
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec 2ec6a50 |
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| lab/TransferList | 142.3 kB (+13 B) · 1.2 kB CSS (0) | — | — · — · — |
| charts/ChartTooltip | 230.9 kB (+11 B) · 451 B CSS (0) | — | — · — · — |
| AlertDialog | 136.5 kB (+10 B) · 16.3 kB CSS (0) | — | — · — · — |
121 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| CommandPaletteInput | 34.7 kB (+10 B) · 8.3 kB CSS (0) | — | — · — · — |
| ChatMessageList | 29.1 kB (+9 B) · 7.8 kB CSS (0) | — | — · — · — |
| DropdownMenu | 136.3 kB (+9 B) · 19.9 kB CSS (0) | — | — · — · — |
| Pagination | 157.4 kB (+9 B) · 20.2 kB CSS (0) | — | — · — · — |
| ChatComposerInput | 90.6 kB (+8 B) · 12.6 kB CSS (0) | — | — · — · — |
| ChatComposerTokenElement | 90.6 kB (+8 B) · 12.6 kB CSS (0) | — | — · — · — |
| Spinner | 25.7 kB (+8 B) · 6.9 kB CSS (0) | — | — · — · — |
| TableHeaderCell | 110.8 kB (+8 B) · 20.1 kB CSS (0) | — | — · — · — |
| lab/VideoPlayer | 239.9 kB (+8 B) · 2.1 kB CSS (0) | — | — · — · — |
| ChatToolCalls | 33.6 kB (+7 B) · 9.2 kB CSS (0) | — | — · — · — |
| EmptyState · Storybook | 7.2 kB (+7 B) · 510 B CSS (0) | 146 (0) | ✓ · ✓ · — |
| IconButton | 69.7 kB (+7 B) · 11.2 kB CSS (0) | — | — · — · — |
| InputGroup | 65.4 kB (+7 B) · 9.2 kB CSS (0) | — | — · — · — |
| TableCell | 110.9 kB (+7 B) · 20.3 kB CSS (0) | — | — · — · — |
| TimeInput | 184.3 kB (+7 B) · 17.9 kB CSS (0) | — | — · — · — |
| Avatar | 48.3 kB (+6 B) · 6.3 kB CSS (0) | — | — · — · — |
| AvatarGroup | 51.1 kB (+6 B) · 6.4 kB CSS (0) | — | — · — · — |
| BreadcrumbItem | 106.0 kB (+6 B) · 14.1 kB CSS (0) | — | — · — · — |
| Button | 69.6 kB (+6 B) · 11.2 kB CSS (0) | — | — · — · — |
| Carousel | 80.2 kB (+6 B) · 12.2 kB CSS (0) | — | — · — · — |
| ChatLayoutScrollButton | 70.2 kB (+6 B) · 11.4 kB CSS (0) | — | — · — · — |
| ChatSendButton | 70.1 kB (+6 B) · 11.2 kB CSS (0) | — | — · — · — |
| CheckboxListItem | 84.8 kB (+6 B) · 12.8 kB CSS (0) | — | — · — · — |
| DateTimeInput | 236.3 kB (+6 B) · 20.7 kB CSS (0) | — | — · — · — |
| DrawerHeader | 73.1 kB (+6 B) · 14.3 kB CSS (0) | — | — · — · — |
| DropdownMenuSubMenu | 82.8 kB (+6 B) · 11.4 kB CSS (0) | — | — · — · — |
| Field | 63.3 kB (+6 B) · 8.0 kB CSS (0) | — | — · — · — |
| FieldLabel | 58.8 kB (+6 B) · 6.5 kB CSS (0) | — | — · — · — |
| InfoTip | 53.4 kB (+6 B) · 6.0 kB CSS (0) | — | — · — · — |
| Markdown | 213.8 kB (+6 B) · 23.6 kB CSS (0) | — | — · — · — |
| MultiSelector | 112.2 kB (+6 B) · 19.0 kB CSS (0) | — | — · — · — |
| RadioListItem | 81.1 kB (+6 B) · 11.5 kB CSS (0) | — | — · — · — |
| SegmentedControl | 105.3 kB (+6 B) · 7.6 kB CSS (0) | — | — · — · — |
| Selector | 124.5 kB (+6 B) · 19.8 kB CSS (0) | — | — · — · — |
| SideNav | 118.0 kB (+6 B) · 12.6 kB CSS (0) | — | — · — · — |
| SideNavCollapseButton | 70.5 kB (+6 B) · 11.3 kB CSS (0) | — | — · — · — |
| SideNavHeading | 91.1 kB (+6 B) · 12.6 kB CSS (0) | — | — · — · — |
| StatusDot | 36.1 kB (+6 B) · 6.0 kB CSS (0) | — | — · — · — |
| Stepper | 71.4 kB (+6 B) · 11.3 kB CSS (0) | — | — · — · — |
| Switch | 113.7 kB (+6 B) · 10.8 kB CSS (0) | — | — · — · — |
| TextArea | 97.1 kB (+6 B) · 10.3 kB CSS (0) | — | — · — · — |
| Tooltip | 34.4 kB (+6 B) · 5.1 kB CSS (0) | — | — · — · — |
| Typeahead | 98.2 kB (+6 B) · 14.5 kB CSS (0) | — | — · — · — |
| lab/AudioPlayer | 242.3 kB (+6 B) · 1.8 kB CSS (0) | — | — · — · — |
| lab/Comments | 394.0 kB (+6 B) · 2.5 kB CSS (0) | — | — · — · — |
| lab/CommentThread | 387.1 kB (+6 B) · 2.4 kB CSS (0) | — | — · — · — |
| lab/Schedule | 121.4 kB (+6 B) · 3.9 kB CSS (0) | — | — · — · — |
| lab/TransferListSelector | 154.5 kB (+6 B) · 1.4 kB CSS (0) | — | — · — · — |
| Banner | 71.7 kB (+5 B) · 11.7 kB CSS (0) | — | — · — · — |
| ChatComposer | 93.5 kB (+5 B) · 13.6 kB CSS (0) | — | — · — · — |
| ChatLayout | 93.5 kB (+5 B) · 11.7 kB CSS (0) | — | — · — · — |
| CheckboxList | 77.4 kB (+5 B) · 8.5 kB CSS (0) | — | — · — · — |
| CommandPalette | 84.7 kB (+5 B) · 13.8 kB CSS (0) | — | — · — · — |
| ContextMenu | 109.8 kB (+5 B) · 19.7 kB CSS (0) | — | — · — · — |
| DateInput | 212.1 kB (+5 B) · 19.0 kB CSS (0) | — | — · — · — |
| DateRangeInput | 109.2 kB (+5 B) · 14.3 kB CSS (0) | — | — · — · — |
| DialogHeader | 72.9 kB (+5 B) · 12.9 kB CSS (0) | — | — · — · — |
| FileInput | 79.8 kB (+5 B) · 12.9 kB CSS (0) | — | — · — · — |
| MoreMenu | 136.6 kB (+5 B) · 19.9 kB CSS (0) | — | — · — · — |
| NumberInput | 108.6 kB (+5 B) · 13.1 kB CSS (0) | — | — · — · — |
| PowerSearch | 323.7 kB (+5 B) · 27.4 kB CSS (0) | — | — · — · — |
| RadioList | 64.8 kB (+5 B) · 8.0 kB CSS (0) | — | — · — · — |
| SideNavItem | 85.2 kB (+5 B) · 12.5 kB CSS (0) | — | — · — · — |
| TabMenu | 87.4 kB (+5 B) · 12.5 kB CSS (0) | — | — · — · — |
| TextInput | 103.6 kB (+5 B) · 12.9 kB CSS (0) | — | — · — · — |
| Thumbnail | 74.2 kB (+5 B) · 12.8 kB CSS (0) | — | — · — · — |
| Toast | 109.7 kB (+5 B) · 11.5 kB CSS (0) | — | — · — · — |
| ToggleButton | 97.2 kB (+5 B) · 11.3 kB CSS (0) | — | — · — · — |
| TopNavMegaMenu | 84.4 kB (+5 B) · 13.2 kB CSS (0) | — | — · — · — |
| lab/ChatReactionBar | 132.8 kB (+5 B) · 1.1 kB CSS (0) | — | — · — · — |
| lab/CommentComposer | 190.2 kB (+5 B) · 1.9 kB CSS (0) | — | — · — · — |
| lab/CommentPin | 63.2 kB (+5 B) · 1.2 kB CSS (0) | — | — · — · — |
| lab/MediaPlayButton | 232.5 kB (+5 B) · 1.5 kB CSS (0) | — | — · — · — |
| lab/MediaSeekButton | 232.5 kB (+5 B) · 1.5 kB CSS (0) | — | — · — · — |
| lab/MediaTime | 232.5 kB (+5 B) · 1.5 kB CSS (0) | — | — · — · — |
| lab/SelectableCardGroup | 73.7 kB (+5 B) · 162 B CSS (0) | — | — · — · — |
| richtext/RichTextEditor | 313.2 kB (+5 B) · 2.7 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditorToolbar | 319.7 kB (+5 B) · 454 B CSS (0) | — | — · — · — |
| AppShell | 93.9 kB (+4 B) · 15.0 kB CSS (0) | — | — · — · — |
| AvatarGroupOverflow | 54.4 kB (+4 B) · 6.3 kB CSS (0) | — | — · — · — |
| BaseTypeahead | 86.6 kB (+4 B) · 12.2 kB CSS (0) | — | — · — · — |
| Calendar | 80.9 kB (+4 B) · 11.8 kB CSS (0) | — | — · — · — |
| ChatDictationButton | 70.2 kB (+4 B) · 11.3 kB CSS (0) | — | — · — · — |
| CheckboxInput | 73.4 kB (+4 B) · 10.9 kB CSS (0) | — | — · — · — |
| CodeBlock | 85.8 kB (+4 B) · 12.9 kB CSS (0) | — | — · — · — |
| Lightbox | 153.6 kB (+4 B) · 12.4 kB CSS (0) | — | — · — · — |
| Link | 59.7 kB (+4 B) · 7.8 kB CSS (0) | — | — · — · — |
| ListItem | 84.0 kB (+4 B) · 12.8 kB CSS (0) | — | — · — · — |
| MobileNav | 82.1 kB (+4 B) · 11.8 kB CSS (0) | — | — · — · — |
| Popover | 108.1 kB (+4 B) · 15.7 kB CSS (0) | — | — · — · — |
| Slider | 119.0 kB (+4 B) · 9.6 kB CSS (0) | — | — · — · — |
| Table | 129.2 kB (+4 B) · 21.3 kB CSS (0) | — | — · — · — |
| TableSelectionToolbar | 80.3 kB (+4 B) · 14.6 kB CSS (0) | — | — · — · — |
| TopNav | 73.3 kB (+4 B) · 12.1 kB CSS (0) | — | — · — · — |
| TopNavHeading | 90.8 kB (+4 B) · 12.6 kB CSS (0) | — | — · — · — |
| lab/ChatEmojiPicker | 131.6 kB (+4 B) · 773 B CSS (0) | — | — · — · — |
| lab/DialogHeroHeader | 94.4 kB (+4 B) · 372 B CSS (0) | — | — · — · — |
| lab/DiffViewer | 98.8 kB (+4 B) · 2.3 kB CSS (0) | — | — · — · — |
| lab/ListInput | 99.5 kB (+4 B) · 922 B CSS (0) | — | — · — · — |
| lab/MediaCaptionsButton | 232.5 kB (+4 B) · 1.5 kB CSS (0) | — | — · — · — |
| lab/MediaFullscreenButton | 232.5 kB (+4 B) · 1.5 kB CSS (0) | — | — · — · — |
| lab/MediaPlaybackRate | 232.5 kB (+4 B) · 1.5 kB CSS (0) | — | — · — · — |
| lab/MediaTimeSlider | 232.5 kB (+4 B) · 1.5 kB CSS (0) | — | — · — · — |
| lab/MediaVolume | 232.5 kB (+4 B) · 1.5 kB CSS (0) | — | — · — · — |
| richtext/RichTextView | 289.9 kB (+4 B) · 2.4 kB CSS (0) | — | — · — · — |
| charts/Chart | 254.4 kB (+3 B) · 516 B CSS (0) | — | — · — · — |
| TopNavMenu | 90.2 kB (+3 B) · 12.6 kB CSS (0) | — | — · — · — |
| lab/TabBarMoreList | 107.4 kB (+3 B) · 1.8 kB CSS (0) | — | — · — · — |
| lab/TourStep | 99.2 kB (+3 B) · 691 B CSS (0) | — | — · — · — |
| ComplexSelector | 86.5 kB (+2 B) · 13.3 kB CSS (0) | — | — · — · — |
| NavHeadingMenuItem | 19.9 kB (+2 B) · 7.0 kB CSS (0) | — | — · — · — |
| MobileNavToggle | 71.5 kB (+1 B) · 11.8 kB CSS (0) | — | — · — · — |
| Timer | 14.5 kB (+1 B) · 6.7 kB CSS (0) | — | — · — · — |
| ProgressBar | 12.6 kB (0) · 7.0 kB CSS (0) | — | — · — · — |
| Text | 12.0 kB (0) · 6.1 kB CSS (0) | — | — · — · — |
| Timestamp | 28.4 kB (0) · 11.5 kB CSS (0) | — | — · — · — |
| lab/EmojiPicker | 123.3 kB (0) · 751 B CSS (0) | — | — · — · — |
| Heading | 12.9 kB (−1 B) · 6.1 kB CSS (0) | — | — · — · — |
| Tokenizer | 116.4 kB (−2 B) · 22.0 kB CSS (0) | — | — · — · — |
| lab/LineClamp | 14.6 kB (−2 B) · 168 B CSS (0) | — | — · — · — |
| charts/ChartLegend | 42.6 kB (−4 B) · 224 B CSS (0) | — | — · — · — |
Package size: @astryxdesign/core 8.03 MB packed (+95 B); no new dependencies.
Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Requesting changes: the hook reorder, tests and spec sentence look right, but the description cites a performance rule that does not exist.
- The description cites
architecture:component-performanceINV18, but no such record exists; the rule it paraphrases isarchitecture:react-component-runtimeINV18 ("Layout is read as little as possible"), which covers layout reads only, so cite that clause and what it covers, or drop the citation.
This needs only a description edit. Two optional points: checkVisibility() forces a style update rather than layout, so the release note and the new code comment could say that; and inside a live region the hook no longer re-arms content hidden by CSS, which matters only if an ancestor's live role changes while the owner stays mounted. CI has not run on this draft head.
Claims and files checked
Review mode: same-head; reason: none
- Claim: inside a live region, EmptyState read its visibility before deciding to stay silent. Verified: the base's first guard calls
checkVisibility()before the live-region check (useAnnounceRenderedText.ts, base lines 202-215). - Claim: the hidden-ancestor and live-region checks now run before the visibility read, and the decisions are the same. Verified (head lines 202-217): the hidden check already ran first on the base, and one re-arm difference remains when an ancestor's live role changes while the content is hidden by CSS (non-blocking).
- Claim: the owners that skip the first render are EmptyState, Spinner and ChatComposer. Verified (
AnnounceRenderedText.tsx:25,Spinner.tsx:487,ChatComposer.tsx:512). - Claim: a forced read during a commit can cost a frame on a busy page. Not measured in the pull request; stated as a possibility only.
- Claim: a performance record's INV18 asks components to read layout and style as little as possible. False: the named record does not exist, and the matching INV18 covers layout reads only.
- Claim: EmptyState's AR3 and the status-announcement spec's FR4 require silence inside a live region. Verified (FR4; FR11 applies FR4 inside a mounted live container; the AR3 verification row).
- Claim: AR3's text now says what its verification row already tested. Verified (
EmptyState.spec.md:145-146against the AR3 row). - Claim: the new live-region case fails on the base. Verified by reading: the base calls the stubbed
checkVisibility()once before returning. - Claim: outside a live region the visibility read still happens and the message is announced once. Verified (
EmptyState.announce.test.tsx:164-189; head lines 214-217). - Claim: the scope is EmptyState and the announcement hook, with no new public API, visual representation, default or interaction model. Verified.
- Claim: the public text carries no internal context. Verified.
- Claim: the overlapping open fix in the same hook changes a different hunk. Verified: it changes the
renderedWithPageinitialiser (lines 185-193), apart from this change's lines 202-217. - Claim: the listed test, type, lint, knowledge and changeset checks pass. Not verified: CI skipped every job on the draft head, and dependencies could not be installed for this review.
- Release note: inside a live region EmptyState no longer forces a style and layout read, and announcements are unchanged. Verified that the read is gone and announcements match; "layout" overstates the saved work (non-blocking).
- File
.changeset/emptystate-live-ancestor-before-visibility.md: wording note (non-blocking). - File
docs/specs/components/EmptyState/EmptyState.spec.md: clear. - File
packages/core/src/EmptyState/EmptyState.announce.test.tsx: clear. - File
packages/core/src/hooks/useAnnounceRenderedText.ts: clear; comment wording and re-arm notes (non-blocking).
|
/approve-spec ae383da |
There was a problem hiding this comment.
Approved pending CI: the hook reorder, the two tests, the spec sentence and the description all check out, and CI is still running on this head; the EmptyState announcement tests, the type check and lint have already passed there.
Next step: let the remaining required checks finish; the merge guard needs them green before merge.
One optional point: inside a live region the hook no longer re-arms content hidden by CSS, which matters only if an ancestor's live role changes while the owner stays mounted.
Claims and files checked
Review mode: same-head; reason: none
- changed rules (0): none
- Claim: inside a live region, EmptyState read its visibility before deciding to stay silent. Verified: the base's first guard calls
checkVisibility()before the live-region check (useAnnounceRenderedText.ts, base lines 202-215). - Claim: every such EmptyState pays a forced style update for no announcement. Verified: on the base the read runs on every render of the owner before the silent return.
- Claim: announcements do not change, and the decisions are the same with only their order changed. Verified (head lines 202-217): the hidden check already ran first on the base; one re-arm difference remains when an ancestor's live role changes while the content is hidden by CSS (non-blocking).
- Claim: the owners that skip the first render are EmptyState, Spinner and ChatComposer. Verified (
AnnounceRenderedText.tsx:25,Spinner.tsx:487,ChatComposer.tsx:512). - Claim: a forced style update during a commit adds main-thread work on a busy page. Stated as a prediction; not measured.
- Claim: the runtime record's rule on layout reads asks components to read layout as little as possible, and an unneeded style read is the same kind of work. Verified: the rule reads "Layout is read as little as possible"; the second half is the author's own reasoning.
- Claim: EmptyState's accessibility rule and the status-announcement spec require silence inside a live container. Verified (the spec's live-container rule, which its appear-later rule applies inside a mounted live container; the EmptyState verification row).
- Claim: the EmptyState rule text now says what its verification row already tested. Verified (
EmptyState.spec.md:145-146against the verification row). - Claim: the new live-container case fails on the base, where
checkVisibilityis called once. Verified by reading: the base calls the stubbedcheckVisibility()once, in the Effect after the empty state mounts, before returning. - Claim: outside a live container the visibility read still happens and the message is announced once. Verified (
EmptyState.announce.test.tsx:164-189; head lines 214-217). - Claim: the scope is EmptyState and the announcement hook, with no new public API, visual representation, default or interaction model. Verified.
- Claim: the public text carries no internal context. Verified.
- Claim: the overlapping open fix in the same hook changes a different hunk. Verified: it changes the
renderedWithPageinitialiser (lines 185-193), apart from this change's lines 202-217. - Claim: the listed test, type, lint, knowledge, comment-provenance and changeset checks pass. Partly verified: on this head CI's type check, lint and the unit-test shard that runs the EmptyState announcement file (all 10 cases passing) succeeded; two unit-test shards and the browser interaction jobs were still running.
- Release note: inside a live region EmptyState no longer forces a style update when it appears; it checks for the live region first; announcements are unchanged. Verified.
- File
.changeset/emptystate-live-ancestor-before-visibility.md: clear. - File
docs/specs/components/EmptyState/EmptyState.spec.md: clear. - File
packages/core/src/EmptyState/EmptyState.announce.test.tsx: clear. - File
packages/core/src/hooks/useAnnounceRenderedText.ts: clear; re-arm note (non-blocking).
User impact
When an EmptyState appears inside an element that is already a live region (a
role="status"orrole="log"container, for example), the shared announcement hook first reads the element's visibility withcheckVisibility(), which forces a style update, and only then finds the live region and decides to say nothing. Every such EmptyState pays a forced style update for no announcement. Announcements do not change.Problem and solution fit
useAnnounceRenderedTextchecks visibility before it walks up to a live-region ancestor, although inside a live region it never announces.architecture:react-component-runtimeINV18 asks components to read layout as little as possible; a style read the component does not need is the same kind of work.The fix moves the cheap ancestor walk before the visibility read, so the read happens only when an announcement can still happen.
Expected behavior and authority
spec:AST-086FR4: inside a live container, the container speaks its content and EmptyState announces nothing.architecture:react-component-runtimeINV18: layout is read as little as possible.Smallest restoration
hooks/useAnnounceRenderedText.ts: the[aria-hidden]/[hidden]ancestor check and the live-region ancestor walk (for owners that skip the first render, as EmptyState, Spinner and ChatComposer do) now run beforecheckVisibility(). The decisions are the same; only their order changes.EmptyState.spec.md: AR3's rule text now says what its verification row already tested. Inside an element that is already a live region, EmptyState announces nothing, and that region speaks its content.Evidence
checkVisibilityis called once for an EmptyState inside arole="status"container.EmptyState.announce.test.tsx, "reads no visibility for an empty state inside a live container, and announces nothing".Scope
Components: EmptyState, hooks (useAnnounceRenderedText)
Writing rubric results
Testing
vitest run --project ui packages/core/src/EmptyState packages/core/src/hooks/useAnnounceRenderedText.test.tsx packages/core/src/hooks/useAnnounceRenderedText.adopters.test.tsx packages/core/src/Spinner packages/core/src/Chat: 639 passed. The new live-container case fails on the base.tsc --noEmit -p packages/coreclean; ESLint clean;check:knowledgealigned; comment-provenance baseline andcheck:changesetspass.Overlap checked: #13567 (a contributor fix in the same hook for rendering without a document; it changes the
renderedWithPageinitialiser, a different hunk from this PR's effect-order change, so either can merge first)