Skip to content

perf(CheckboxInput): the disabled-message tooltip runs only while it can show - #12376

Merged
cixzhang merged 7 commits into
mainfrom
perf/checkbox-input-instance-cost
Nov 19, 2026
Merged

cixzhang merged 7 commits into
mainfrom
perf/checkbox-input-instance-cost

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Primary intent

Performance: a CheckboxInput whose disabled message cannot show runs none of the tooltip's work, so a page with many checkboxes (a permissions matrix, a table with a selection column) renders faster.

User impact

  • People opening a page with many checkboxes wait less. On 1,000 checkboxes at 6× CPU in Chromium (production build), render plus commit took a median 710 ms on main, and useTooltip with its hooks was about 21 % of it, run by every checkbox, though the tooltip can show only on a disabled checkbox with a disabledMessage. With this change the same page mounts in a median 426 ms against 719 ms on its base, 41 % less, and useTooltip and useLayer no longer appear in the profile.
  • People reaching a disabled checkbox before the page hydrates (a slow network, streamed HTML) now hear its reason: the server markup names it in aria-describedby. This also fixes a defect on main, where that aria-describedby named a tooltip the server markup did not contain, so the reason was missing until hydration (spec:AST-013 FR9; component:CheckboxInput FR6). The CheckboxInput record has no gap line for it, so no record changes.
  • Otherwise no behavior change: a disabled checkbox with a disabledMessage shows the same tooltip, from the same row hover or focus, anchored above the checkbox, and keeps the message as its description, exactly once. Once mounted, the reason renders once, in the tooltip, as on main.

The change

  • CheckboxInput.tsx: the reason's id is owned by the checkbox (useId) and named in aria-describedby during render. The tooltip moves into a small internal component that mounts only while isDisabled and disabledMessage are both set; it attaches its hover and focus listeners to the row and its anchor to the checkbox, which the parent renders, and its text is a <span> carrying that id. The server and hydrating markup has no tooltip layer, so while useIsHydrating() is true a visually hidden copy carries the id instead (spec:AST-013 FR9; component:CheckboxInput FR4, FR6). One layout Effect wires the tooltip to the row and the checkbox when it mounts; the hand-off of the description needs no Effect or observer, and Tooltip is unchanged.
  • No API, default or markup change for a checkbox without a showable message; no public API change.

Evidence

  • Red first: CheckboxInput.tooltipCost.test.tsx wraps useTooltip in a spy. On main, a page of checkboxes with no showable message calls it (fails); with this change it does not. CheckboxInput.ssr.test.tsx: the renderToString markup of a disabled checkbox names an element whose text is the reason (fails on main, whose described id is not in the server markup), and hydration logs no mismatch.
  • Updated and added: two disabledMessage cases that read the tooltip's id now assert the accessible description itself (the reason exactly once, after a caller's own aria-describedby), and a new case checks the reason renders once after mount, in the tooltip that the input names.
  • Unchanged paths: the CheckboxInput, CheckboxListItem, CheckboxList and Table suites pass (1,119 tests in 55 files), including every disabledMessage case (tooltip on hover and focus, aria-describedby, a caller aria-describedby alongside it, form submission while disabled). Core tsc and strict lint pass.
  • Benchmark: 1,000 <CheckboxInput isLabelHidden> in one list, flushSync render to the list's layout effect, Chromium headless at 6× CPU, production build, 1 warm-up and 3 rounds. At this head (180143f), in one session: median 426 ms; the previous head 2f3567e: 423 ms; the base d504f00: 719 ms (−41 %). Every head run (416–431 ms) is below every base run (704–764 ms). Measured on the device farm's Chromium (149).

Size and element counts

  • First-load JavaScript (pnpm size:pages, base d504f00 → this head, gzip), pages without a disabledMessage, against INV10's 307 B limit: CheckboxInput alone +201 B, docs +0 B, form +139 B, menu +45 B, table +29 B (all pass).
  • Elements (INV7): a checkbox without a reason is unchanged. A disabled checkbox with a reason has one more element than main in the server markup (12 → 13: the visually hidden copy) and one more once mounted: the <span> inside the tooltip that carries the id aria-describedby names (INV5: an ARIA need). The reason's text renders once in both.

…can show

Every checkbox called useTooltip, though the tooltip shows only when the checkbox is disabled and has a disabledMessage. On 1,000 checkboxes at 6x CPU in Chromium, useTooltip and its hooks were about a fifth of render and commit. The tooltip now lives in a child component that mounts only while the message can show; it attaches to the row and the checkbox, and reports its description id for the input's aria-describedby (an empty id is left out).
@vercel

vercel Bot commented Nov 17, 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 18, 2026 9:29pm UTC

Request Review

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

astracat-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 19, 2026, 3:59 AM UTC

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

Copy link
Copy Markdown
Contributor Author

/approve-spec 2f3567e

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 9ae1d5c

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
LayerProvider 4.4 kB (0) · 20 B CSS (0) — ✓ · ✓ · ✗
CheckboxInput · Storybook 69.6 kB (+214 B) · 10.2 kB CSS (0) 458 (+34) ✓ · ✓ · ✓
ListItem 79.7 kB (+205 B) · 12.1 kB CSS (0) — — · — · —
19 more components
Component Size LoC Visual · A11y · RTL
CheckboxListItem 80.5 kB (+196 B) · 12.1 kB CSS (0) — — · — · —
MultiSelector 103.3 kB (+181 B) · 17.8 kB CSS (0) — — · — · —
richtext/RichTextEditor 307.2 kB (+142 B) · 2.6 kB CSS (0) — — · — · —
lab/CommentThread 370.2 kB (+135 B) · 2.4 kB CSS (0) — — · — · —
lab/Comments 377.0 kB (+134 B) · 2.5 kB CSS (0) — — · — · —
lab/TransferListSelector 145.4 kB (+133 B) · 1.4 kB CSS (0) — — · — · —
Markdown 205.4 kB (+128 B) · 22.1 kB CSS (0) — — · — · —
richtext/RichTextView 283.9 kB (+111 B) · 2.3 kB CSS (0) — — · — · —
lab/TransferList 136.5 kB (+99 B) · 1.2 kB CSS (0) — — · — · —
lab/TabBarMoreList 102.4 kB (+79 B) · 1.8 kB CSS (0) — — · — · —
DropdownMenu 108.8 kB (+38 B) · 18.9 kB CSS (0) — — · — · —
MoreMenu 109.1 kB (+34 B) · 18.9 kB CSS (0) — — · — · —
TableCell 104.6 kB (+33 B) · 19.3 kB CSS (0) — — · — · —
Table 121.8 kB (+32 B) · 19.8 kB CSS (0) — — · — · —
TableHeaderCell 104.5 kB (+31 B) · 19.1 kB CSS (0) — — · — · —
ContextMenu 103.3 kB (+11 B) · 18.8 kB CSS (0) — — · — · —
PowerSearch 310.2 kB (+1 B) · 25.6 kB CSS (0) — — · — · —
layer — — — · ✓ · —
Layer — — ✓ · ✓ · —

Package size: @astryxdesign/core 7.66 MB packed (+1.1 kB); 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

… server markup

The reason renders once in a visually hidden element whose id the input names in aria-describedby during render, so it is there before hydration and before the tooltip mounts or shows (spec:AST-013 FR9; component:CheckboxInput FR4, FR6). The tooltip still mounts only while the reason can show; its text is hidden from assistive technology, so the reason describes the checkbox once. An SSR test checks the server markup and a clean hydration.
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 180143f

@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.

Changes requested. Moving the disabled-message tooltip into a child that mounts only while it can show is sound, and the new tests prove both the cost saving and the server-markup fix, but two points need fixing first.

  • The reason now renders twice for a disabled checkbox with a disabledMessage: once in the visually hidden copy at CheckboxInput.tsx:655 and once in the tooltip text at :702. That takes the DisabledWithMessage story from 119 to 121 elements, and CheckboxInput's minimal-DOM rule (component-style-authoring INV7, AST-017 FR60) allows it only with a stated, owner-recorded exception and element counts, so either render the reason once (for example, reference the tooltip's text only once its layer is in the document) or state and record that exception.
  • The changeset says "Behavior is unchanged", but a disabled checkbox's reason now describes it in the server markup before hydration and sits in the screen-reader reading order, so the release note should describe what ships.

Smaller, non-blocking suggestions are inline: a long comment at CheckboxInput.tsx:418-420, the per-checkbox useId, and stating the first-load gzip delta (+174 B for CheckboxInput alone, +40 B on the form reference page). CI has not run on this head yet.

Claims and files checked

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

  • Claim: the tooltip runs only while a disabled message can show. Verified (CheckboxInput.tsx:653-664; the tooltip-cost test fails on the base and passes here).
  • Claim: pages with many checkboxes render faster. The mechanism is verified (no tooltip hook calls without a showable message); the timing was not reproduced.
  • Claim: behavior is unchanged (changeset). False: the server markup and the reading order change.
  • Claim: render and commit took 710 ms on main, about 21% of it in the tooltip hooks. Author measurement, not reproduced.
  • Claim: 428 ms against 749 ms on its base. Author measurement, not reproduced.
  • Claim: the tooltip and layer hooks leave the profile. Consistent with the tooltip-cost test (0 calls).
  • Claim: before hydration the reason describes the checkbox, while the base named an element missing from the server markup. Verified (the server-markup test fails on the base and passes here).
  • Claim: same tooltip, same row hover and focus, anchored on the checkbox. Verified (hover and focus frames are pixel-identical; the suites pass).
  • Claim: the message stays the description exactly once. Verified for the accessible description; the page now holds the reason twice (first finding).
  • Claim: the reason renders once in a hidden element. False: it also renders in the tooltip.
  • Claim: nothing changes for a checkbox without a showable message, and the public API is unchanged. Verified (the API comparison is empty; the hidden copy renders only with a reason).
  • Claim: the new tests fail on the base and pass here. Verified.
  • Claim: the updated tests assert the description after a caller's own description. Verified.
  • Claim: the CheckboxInput, CheckboxList and Table suites, typecheck and lint pass. Verified (212 and 1,016 tests pass; typecheck passes; lint shows 0 errors).
  • Claim: the benchmark predates the hidden copy, which adds no work without a reason. Mostly true: every checkbox now calls one id hook.
  • File: .changeset/checkbox-input-tooltip-only-when-shown.md. Finding (false "unchanged").
  • File: packages/core/src/CheckboxInput/CheckboxInput.tsx. Finding (the reason renders twice); comment suggestion.
  • File: packages/core/src/CheckboxInput/CheckboxInput.ssr.test.tsx. Clear.
  • File: packages/core/src/CheckboxInput/CheckboxInput.test.tsx. Clear.
  • File: packages/core/src/CheckboxInput/CheckboxInput.tooltipCost.test.tsx. Clear.

Automated review (maintainer link)

Comment on lines 418 to +420
// The disabled-message tooltip listens for hover and focus on the whole
// row, a larger trigger. It anchors on the checkbox itself (below), so it
// shows next to the control. Its handlers check isEnabled, so the row
// always attaches them.
const rowRef = useMergedRefs(
disabledMessageTooltip.interactionRef,
watchRowHitArea,
);
// row, a larger trigger, and anchors on the checkbox itself, so it shows
// next to the control.

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: this is one 28-word sentence with three topics. A shorter form: "The tooltip listens for hover and focus on the whole row, a larger trigger. It anchors on the checkbox, so it shows next to the control."

The visually hidden copy describes the input in the server markup and until the tooltip's text is in the document; then the tooltip describes it and the copy goes, so a disabled checkbox with a reason renders the text once, as on main. The changeset names the server-markup fix.
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 93ff0b1

@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.

Changes requested: both earlier blockers are fixed (the reason now renders once after mount, and the changeset describes the server-markup change), but two new points need fixing.

  • The hand-off at CheckboxInput.tsx:731-737 gives every disabled checkbox with a reason its own MutationObserver on the whole document (200 such checkboxes create 200 observers and 40,000 mutation records), which CheckboxInput's record (PR1: "The component owns no global listener or observer") and the runtime rules on shared observers (react-component-runtime INV7 and INV16) do not allow, so please let useTooltip report when its surface is in the document, from the layer's own ref callback, and keep no Effect or observer for it in CheckboxInput.
  • A page that renders CheckboxInput without a disabledMessage now loads 326 B more gzip JavaScript (67,788 B to 68,114 B), over the 0.3 KB (307 B) that component-import-boundaries INV10 allows an optional feature, and 152 B of that growth came with the hand-off code above.

Approval also waits on the description stating the INV10 first-load deltas for CheckboxInput's own page and the four reference pages (measured here: docs +164 B, form +178 B, menu +155 B, table +162 B) and the INV7 element counts for the hidden copy in the server markup (12 to 13 elements). CI has not run on this head yet, and the non-blocking notes are inline.

Claims and files checked

Review mode: incremental; reason: none

  • Claim (changeset): the tooltip runs only while a disabled message can show. Verified: the child mounts only while disabled with a message (CheckboxInput.tsx:657-671), and the tooltip-cost test fails on the base and passes here.
  • Claim (changeset): a page of many checkboxes renders faster. Mechanism verified for checkboxes without a showable message; the timing was not reproduced.
  • Claim (changeset): a disabled checkbox's reason now describes it in the server HTML before hydration. Verified: the server-markup test fails on the base and passes here.
  • Claim: on 1,000 checkboxes, main takes 710 ms and the tooltip hooks are about 21% of it. Author measurement, not reproduced.
  • Claim: the change mounts the same page in 426 ms against 719 ms, and the tooltip and layer hooks leave the profile. Author measurement at an earlier head, not reproduced; consistent with zero hook calls in the tooltip-cost test.
  • Claim: server markup now names the reason, fixing main, where the described element was missing before hydration. Verified (red-first server-markup test).
  • Claim: the CheckboxInput record has no gap line for this, so no record changes. Verified: the record lists no such gap.
  • Claim: otherwise no behavior change, with the same tooltip from the same row hover or focus, anchored above, described exactly once. Verified: hover and focus frames are pixel-identical in a real browser, and the description tests pass.
  • Claim: once mounted, the reason renders once, in the tooltip. Verified: 119 elements and one copy on both trees in a real browser, and the new test.
  • Claim: the hidden copy is named during render, and the tooltip takes over once its text is in the document. Verified; the takeover uses a per-checkbox document observer (first finding).
  • Claim: no API, default or markup change for a checkbox without a showable message, and no public API change. Verified: the API comparison is empty and a plain checkbox's server markup is unchanged.
  • Claim: the new tests fail on main and pass here, and hydration logs no mismatch. Verified.
  • Claim: two updated cases and one new case assert the description itself. Verified.
  • Claim: the CheckboxInput, CheckboxListItem, CheckboxList and Table suites, typecheck and strict lint pass. Verified: 1,331 tests across the CheckboxInput, CheckboxList, Table and List suites pass, typecheck passes, and lint shows no errors.
  • Claim: the benchmark setup (1,000 checkboxes, 6x CPU, production build, three rounds). Author measurement, not reproduced.
  • File: .changeset/checkbox-input-tooltip-only-when-shown.md. Clear.
  • File: packages/core/src/CheckboxInput/CheckboxInput.tsx. Findings: the per-checkbox document observer and the first-load growth; one comment suggestion.
  • File: packages/core/src/CheckboxInput/CheckboxInput.ssr.test.tsx. Clear.
  • File: packages/core/src/CheckboxInput/CheckboxInput.test.tsx. Clear.
  • File: packages/core/src/CheckboxInput/CheckboxInput.tooltipCost.test.tsx. Clear.

Automated review (maintainer link)

…ace's own ref

useTooltip gains an internal onSurfaceMount callback, driven by the layer surface's ref, so CheckboxInput learns when the tooltip text is in the document without a document observer. The per-checkbox MutationObserver is gone.
The surface callback moves to useTooltipInternal(options, {onSurfaceMount}), which the package does not export. Public useTooltip calls it with no internal options, so TooltipOptions is unchanged. CheckboxInput imports the internal entry.
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 2891d16

@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.

Changes requested: one blocker remains.

  • useTooltipInternal and TooltipInternalOptions (packages/core/src/Tooltip/useTooltip.tsx:185-192, :292-299) form a new hook that CheckboxInput imports from Tooltip and no current record defines, so architecture:knowledge-contracts DEC-22 needs a recorded owner decision: add a record (for example a module record under component:Tooltip) that shows its usage, why CheckboxInput needs it and why the public useTooltip is not enough, then approve that head with /approve-spec, or report the surface through the public hook instead (for example a callback ref on the content passed to renderTooltip).

The /approve-spec already on this head does not settle it, because the pull request changes no record that could define the hook. Non-blocking: the useTooltip.tsx header's @output still names only useTooltip, and the open comment-length and useId notes still apply. Everything else checks out: the new tests fail on the base and pass here, the mounted tooltip is unchanged, and a page with CheckboxInput alone grows 296 B gzip, under the 307 B limit.

Claims and files checked

Review mode: same-head; reason: none

  • Claim: the tooltip runs only while its message can show. Verified: the tooltip-cost test fails on the base (21 hook calls) and passes here.
  • Claim: a disabled checkbox's reason describes it in the server markup, fixing a reference to a missing element. Verified: the server-markup test fails on the base and passes here with a clean hydration.
  • Claim: render timings (710 ms on the base; 426 ms against 719 ms, 41% less). Not reproduced; measured at an earlier commit; the removed hook calls are verified.
  • Claim: the CheckboxInput record has no gap line for the server-markup defect. Verified.
  • Claim: no behavior change once mounted (same tooltip, triggers, anchor, one description). Verified: the suites pass, and browser frames at rest, hover and focus are pixel-identical with one copy of the reason.
  • Claim: a hidden copy with its own id is named during render, then the tooltip once its surface mounts. Verified: CheckboxInput.tsx:397-399, :659-663, :697-702.
  • Claim: the internal component mounts only while disabled with a reason, listening on the row and anchored on the checkbox. Verified: CheckboxInput.tsx:657-671, :715-722.
  • Claim: the surface is reported from its own ref, with no Effect or observer for it. Verified: useTooltip.tsx:490-494.
  • Claim: the package does not export the internal hook; TooltipOptions and the public API are unchanged. Verified: Tooltip/index.ts re-exports only useTooltip and its types, and the API comparison lists no rows.
  • Claim: no markup change for a checkbox without a showable message. Verified: 11 elements on both.
  • Claim: tests updated and added as described; the CheckboxInput, CheckboxList and Table suites, typecheck and lint pass. Verified: 70 files and 1,448 tests pass; typecheck clean; lint has no errors.
  • Claim: first-load size deltas stay under the 307 B limit. Verified within 16 B: CheckboxInput alone +296 B, docs +29 B, form +236 B, menu +83 B, table +67 B.
  • Claim: server markup grows from 12 to 13 elements and is unchanged once mounted. Verified.
  • Changeset claim: the tooltip runs only while its message can show, and the reason describes the checkbox in server-rendered HTML. Verified, as above.
  • File .changeset/checkbox-input-tooltip-only-when-shown.md: clear.
  • File packages/core/src/CheckboxInput/CheckboxInput.ssr.test.tsx: clear.
  • File packages/core/src/CheckboxInput/CheckboxInput.test.tsx: clear.
  • File packages/core/src/CheckboxInput/CheckboxInput.tooltipCost.test.tsx: clear.
  • File packages/core/src/CheckboxInput/CheckboxInput.tsx: imports the undefined internal hook (blocking); comment and useId notes (non-blocking).
  • File packages/core/src/Tooltip/useTooltip.tsx: adds the undefined internal hook (blocking); stale header (non-blocking).

Automated review (maintainer link)

…Tooltip change

The tooltip's text is a span with the id the input's aria-describedby names. While the server renders and the client hydrates, the tooltip layer has no markup, so a visually hidden copy carries that id instead (useIsHydrating). useTooltip is back to main: no internal entry and no surface callback.
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 8ef2015

@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.

Changes requested: one sentence in the description needs fixing; the code itself checks out.

  • The description says "No Effect, observer or Tooltip change", but DisabledMessageTooltip adds a layout Effect (packages/core/src/CheckboxInput/CheckboxInput.tsx:703-710) that wires the tooltip to the row and the checkbox when it mounts, so please reword it, for example: "One layout Effect wires the tooltip to the row and the checkbox when it mounts; the hand-off needs no Effect or observer, and Tooltip is unchanged."

The earlier blocker is fixed: Tooltip/useTooltip.tsx is back to its state on main, so no internal Tooltip hook needs a record. The new tests fail on the base and pass here, hydration keeps one id and one copy of the reason, the Chromium accessibility suite passes, and a page with CheckboxInput alone grows 210 B gzip, under the 307 B limit. The inline comments carry three non-blocking comment-style notes, a note on the per-checkbox useIsHydrating call, and the benchmark, which was measured at an earlier commit.

Claims and files checked

Review mode: incremental; reason: none

  • Changed rules since the last review: none.
  • Claim: a checkbox whose message cannot show runs none of the tooltip's work. Verified: the tooltip-cost test fails on the base (21 hook calls) and passes here.
  • Claim: render timings (710 ms on main; 426 ms against 719 ms, 41% less). Not reproduced: measured at an earlier commit, which the description calls this head; the removed hook calls are verified.
  • Claim: a disabled checkbox's reason now describes it in the server markup, which fixes a reference to a missing element. Verified: the server-markup test fails on the base and passes here, and hydration is clean.
  • Claim: the CheckboxInput record has no gap line for that defect. Verified.
  • Claim: otherwise no behavior change, with the same tooltip, triggers and anchor and one description once mounted. Verified: the suites pass, Chromium frames at rest, on hover and on focus are pixel-identical, and the reason renders once.
  • Claim: the checkbox owns the reason's id and names it during render; the tooltip mounts only while disabled with a message, listens on the row and anchors on the checkbox; its text is a span carrying the id; a hidden copy carries it while hydrating. Verified: CheckboxInput.tsx:397-398, :492-494, :656-670, :703-712.
  • Claim: no Effect, observer or Tooltip change. False: there is no observer and no Tooltip change, but a layout Effect at CheckboxInput.tsx:703-710.
  • Claim: no API, default or markup change for a checkbox without a showable message, and no public API change. Verified: 11 server-markup elements on both, and the API comparison lists no rows.
  • Claim: the tests are updated and added as described. Verified in the three CheckboxInput test files.
  • Claim: the CheckboxInput, CheckboxListItem, CheckboxList and Table suites, the core typecheck and strict lint pass. Verified: 70 files and 1,448 tests pass, the typecheck is clean, and lint has no errors.
  • Claim: first-load deltas stay under the 307 B limit (CheckboxInput +201 B, docs +0 B, form +139 B, menu +45 B, table +29 B). Verified within 10 B: +210, +0, +137, +55 and +28 B.
  • Claim: element counts (server markup 12 to 13, one more once mounted, the reason once). Verified: 12 to 13 in server markup, 119 to 120 in the story, one copy.
  • Changeset claim: the tooltip runs only while its message can show, and the reason describes the checkbox in server-rendered HTML before hydration. Verified, as above.
  • File .changeset/checkbox-input-tooltip-only-when-shown.md: clear.
  • File packages/core/src/CheckboxInput/CheckboxInput.ssr.test.tsx: clear.
  • File packages/core/src/CheckboxInput/CheckboxInput.test.tsx: clear.
  • File packages/core/src/CheckboxInput/CheckboxInput.tooltipCost.test.tsx: clear.
  • File packages/core/src/CheckboxInput/CheckboxInput.tsx: its layout Effect is misdescribed (blocking); comment and per-checkbox hook notes (non-blocking).

Automated review (maintainer link)

Comment on lines +393 to +395
// server and hydrating markup has no tooltip layer, so a visually hidden
// copy carries the reason's id there; every later render gives that id to
// the tooltip's text instead, so the reason renders once. The tooltip mounts

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 (INV29): this is one 35-word sentence with three topics. A shorter form: "Server and hydrating markup has no tooltip layer, so a visually hidden copy carries the reason's id there. Later renders give the id to the tooltip's text."

Comment on lines +397 to +398
const disabledMessageID = useId();
const isHydrating = useIsHydrating();

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: both hooks run for every checkbox, including one with no reason, but the header (lines 7-8) says useIsHydrating runs only while a disabled message can show. To make the header and the comment above true, move the hidden copy and useIsHydrating into the conditional child, and derive the id from id (for example ${id}-disabled-reason).

positionRef(null);
};
}, [interactionRef, positionRef, rowRef, inputRef]);
// The span names the reason for the input's aria-describedby.

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 (INV29): this restates the JSDoc at lines 684-686 ("Its text carries the id that describes the input"). Drop it.

@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 is still running its test suites on this head. Typecheck, the builds, visual regression, the accessibility contracts and most test shards have passed so far, and merging waits for the remaining node and UI test shards.

The new tests fail on main and pass here, the reason describes a disabled checkbox in the server markup with a clean hydration, and a page of 1,000 plain checkboxes renders in 297 ms against 515 ms on the base (42% less, Chromium at 6× CPU, production build). The open inline comments carry non-blocking notes: three comment rewrites and the per-checkbox useIsHydrating call that the file header says runs only with a reason; the benchmark also still names an earlier commit as this head.

Claims and files checked

Review mode: same-head; reason: none

  • Claim: a checkbox whose disabled message cannot show runs none of the tooltip's work. Verified: the tooltip-cost test fails on the base (21 hook calls) and passes here; useTooltip runs only in the child at CheckboxInput.tsx:694, which mounts at :656-670.
  • Claim: on main a page of 1,000 checkboxes takes about 710 ms, about a fifth of it in the tooltip hooks; with this change it takes 41% less and the hooks leave the profile. Verified at this head: 297 ms against 515 ms on the base (42% less), every head run faster than every base run, and no tooltip hook runs; the profile share is the author's profile of main, absolute times differ by device, and the commit the description calls this head is an earlier one.
  • Claim: a disabled checkbox's reason now describes it in the server markup, which fixes a reference to a missing element. Verified: the server-markup test fails on the base and passes here, and hydration logs no mismatch.
  • Claim: the CheckboxInput record has no gap line for that defect, so no record changes. Verified.
  • Claim: otherwise no behavior change, with the same tooltip, triggers and anchor, and, once mounted, the reason described and rendered once. Verified: the suites pass, frames at rest, on hover and on focus are pixel-identical, and the reason renders once.
  • Claim: the checkbox owns the reason's id and names it during render; the tooltip mounts only while disabled with a message, listens on the row and anchors on the checkbox; its text is a span carrying the id; a hidden copy carries it while hydrating. Verified: CheckboxInput.tsx:397-398, :492-494, :656-670, :703-712.
  • Claim: one layout Effect wires the tooltip to the row and the checkbox when it mounts; the hand-off needs no Effect or observer; Tooltip is unchanged. Verified: :703-710 is the only Effect, the hand-off is decided in render at :658-665, and no Tooltip file changes.
  • Claim: no API, default or markup change for a checkbox without a showable message, and no public API change. Verified: 11 elements per such checkbox on both, and the API comparison lists no rows.
  • Claim: the tests are updated and added as described. Verified in the three CheckboxInput test files.
  • Claim: the CheckboxInput, CheckboxListItem, CheckboxList and Table suites, the core typecheck and strict lint pass. Verified: the CheckboxInput, CheckboxList and Tooltip suites pass here (330 tests), the Table and List suites too (1,448 tests in all), the typecheck is clean, and CI's lint and typecheck jobs pass on this head.
  • Claim: first-load deltas stay under the 307 B limit (CheckboxInput +201 B, docs +0 B, form +139 B, menu +45 B, table +29 B). Verified within 10 B: +210, +0, +137, +55 and +28 B.
  • Claim: element counts (server markup 12 to 13, one more once mounted, the reason once, none for a checkbox without a reason). Verified.
  • Changeset claim: the tooltip runs only while its message can show, so many-checkbox pages render faster, and the reason describes the checkbox in server-rendered HTML before hydration. Verified, as above.
  • File .changeset/checkbox-input-tooltip-only-when-shown.md: clear.
  • File packages/core/src/CheckboxInput/CheckboxInput.ssr.test.tsx: clear.
  • File packages/core/src/CheckboxInput/CheckboxInput.test.tsx: clear.
  • File packages/core/src/CheckboxInput/CheckboxInput.tooltipCost.test.tsx: clear.
  • File packages/core/src/CheckboxInput/CheckboxInput.tsx: non-blocking comment and per-checkbox hook notes.

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as ready for review November 18, 2026 18:18
@cixzhang
cixzhang marked this pull request as draft November 18, 2026 18:57
@cixzhang
cixzhang marked this pull request as ready for review November 18, 2026 18:57
…he tooltip

CheckboxInput names its own reason text, which sits inside the tooltip
after the first show. The touch-target helper now accepts an
aria-describedby id that resolves inside the reason's tooltip.
@cixzhang
cixzhang marked this pull request as draft November 18, 2026 21:19
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 9ae1d5c

cixzhang added a commit that referenced this pull request Nov 18, 2026
# Conflicts:
#	packages/core/src/CheckboxInput/CheckboxInput.test.tsx
#	packages/core/src/CheckboxInput/CheckboxInput.tsx
cixzhang added a commit that referenced this pull request Nov 18, 2026

@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 started on this head when the pull request was marked ready for review, and lint, typecheck, the builds, every unit-test shard, visual regression and the accessibility and interaction contracts pass, while the docsite browser job is still running.

The change checks out: the new tooltip-cost and server-markup tests fail without this change and pass with it, the disabled reason is the checkbox's description in Chromium's accessibility tree, and the mounted tooltip is pixel-identical at rest, on hover and on focus. The open inline comments carry non-blocking notes (three comment rewrites, and the file header that says useIsHydrating runs only with a reason), and the description's benchmark still names an earlier commit as this head.

Claims and files checked

Review mode: same-head; reason: none

  • Claim: a checkbox whose disabled message cannot show runs none of the tooltip's work. Verified: the tooltip-cost test fails without this change (21 hook calls) and passes here; useTooltip runs only in the child at CheckboxInput.tsx:694, which mounts at :656-670.
  • Claim: a page of 1,000 checkboxes takes about 710 ms, about a fifth of it in the tooltip hooks; with this change it takes 41% less and the hooks leave the profile. Verified with the same shipped code: 297 ms against 515 ms without the change (42% less), every head run faster than every base run, and no tooltip hook runs; the profile share is the author's profile, absolute times differ by device, and the commit the description calls this head is an earlier one.
  • Claim: a disabled checkbox's reason now describes it in the server markup, which fixes a reference to a missing element. Verified: the server-markup test fails without this change and passes here, the server markup held no copy of the reason before and holds one now, and hydration logs no mismatch.
  • Claim: the CheckboxInput record has no gap line for that defect, so no record changes. Verified.
  • Claim: otherwise no behavior change, with the same tooltip, triggers and anchor, and, once mounted, the reason described and rendered once. Verified: frames at rest, on hover and on focus are pixel-identical, the reason renders once, and the accessibility-tree description check passes.
  • Claim: the checkbox owns the reason's id and names it during render; the tooltip mounts only while disabled with a message, listens on the row and anchors on the checkbox; its text is a span carrying the id; a hidden copy carries it while hydrating. Verified: CheckboxInput.tsx:397-398, :492-494, :656-670, :703-712.
  • Claim: one layout Effect wires the tooltip to the row and the checkbox when it mounts; the hand-off needs no Effect or observer; Tooltip is unchanged. Verified: :703-710 is the only Effect, the hand-off is decided in render at :658-665, and no Tooltip file changes.
  • Claim: no API, default or markup change for a checkbox without a showable message, and no public API change. Verified: 11 server elements and 116 story elements before and after, and the API comparison lists no added, changed or removed row in any package.
  • Claim: the tests are updated and added as described. Verified in the three CheckboxInput test files.
  • Claim: the CheckboxInput, CheckboxListItem, CheckboxList and Table suites, the core typecheck and strict lint pass. Verified: the 57 test files that render CheckboxInput or a disabled reason pass (3,848 tests), and CI's typecheck and lint pass on this head.
  • Claim: first-load deltas stay under the 307 B limit (CheckboxInput +201 B, docs +0 B, form +139 B, menu +45 B, table +29 B). Verified within 11 B: +210, +0, +137, +56 and +29 B.
  • Claim: element counts (server markup 12 to 13, one more once mounted, the reason once, none for a checkbox without a reason). Verified: 12 to 13 in server markup, 119 to 120 in the story, and 11 and 116 unchanged without a reason.
  • Changeset claim: the tooltip runs only while its message can show, so many-checkbox pages render faster, and the reason describes the checkbox in server-rendered HTML before hydration. Verified, as above.
  • File .changeset/checkbox-input-tooltip-only-when-shown.md: clear.
  • File packages/core/src/CheckboxInput/CheckboxInput.ssr.test.tsx: clear.
  • File packages/core/src/CheckboxInput/CheckboxInput.test.tsx: clear.
  • File packages/core/src/CheckboxInput/CheckboxInput.tooltipCost.test.tsx: clear.
  • File packages/core/src/CheckboxInput/CheckboxInput.tsx: non-blocking comment and per-checkbox hook notes.
  • File packages/core/src/Layer/touchTriggerTargets.test.tsx: clear; a control that names the tooltip itself still passes.

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as ready for review November 19, 2026 03:39
@cixzhang
cixzhang merged commit d9676b9 into main Nov 19, 2026
150 checks passed
@github-actions
github-actions Bot deleted the perf/checkbox-input-instance-cost branch November 19, 2026 06:04
cixzhang added a commit that referenced this pull request Nov 24, 2026
* perf(Tooltip): the layer mounts at the tooltip's first show

Every Tooltip mounted its layer with its trigger, so a table with a
tooltip on every row mounted hundreds of closed layers and froze for
seconds. The layer now mounts at the first hover, focus, tap or show(),
in the same commit as that show, and then stays. Until then the
trigger's aria-describedby names hidden text with the same content, so
screen readers read the same description; the hidden text and the layer
are never in the page together. Tests that read the closed layer before
any interaction now read the tooltip after it.

* fix(Tooltip): a plain hidden copy describes the trigger until the first show

The stand-in description no longer plays the tooltip role, so the page
holds one tooltip per trigger. It renders through a portal into the
body of the trigger's document, so it sits in no paragraph and no
sibling rule. A server render carries no description and no reference
until it hydrates. TOOLTIP_PATTERN's rows that read the tooltip apply
once it has shown, and a new row checks the hidden copy before then.

* fix(Tooltip): the copy follows the layer's own mount and the trigger's root

The swap from the hidden copy to the tooltip reads the layer runtime's
mount store, so a show that waits for its trigger's box keeps the copy
until the layer mounts. A trigger in a shadow root keeps the copy in
that root. Switch and the MultiSelector status button leave an empty
describedby off. TOOLTIP_PATTERN checks the computed description
before the first show.

* Merge remote-tracking branch 'refs/remotes/l4/main-new' into lane4/tooltip-mount-on-first-intent

* test: read a tooltip's description before its first show

Tests that read a tooltip's layer before it opened now read the
trigger's description: the hidden copy until the layer mounts, then the
tooltip. Tests that need the open tooltip show it first. Each test keeps
its user-visible assertion.

* fix(Tooltip): the status-icon and date-input callers leave an empty describedby off

The field status-icon button and the DateInput, DateTimeInput and
DateRangeInput disabled-reason buttons no longer write an empty
aria-describedby in server and hydrating markup. The changeset states the
measured effect.

* Merge commit '88c4e0a8a7d62d66d678bb457e5d05edae3f88bc' into lane4/tooltip-mount-on-first-intent

* fix(Tooltip): a shadow-root trigger in another window keeps its copy in its root

The description root is found by node type, so a shadow root whose host
moved into an iframe's or another window's document still holds the
hidden copy, where the trigger's aria-describedby can name it.

* fix(Tooltip): a trigger that attaches again in the page moves its copy back

The trigger's ref callback now clears the stored description root when
the trigger attaches in the page's own body, so a hook trigger that
moves out of a shadow root or another window names a copy the page
holds.

* fix(Tooltip): the trigger's description root changes state only when it changes

Fields attach their tooltip through an inline ref at every commit, so
setting the root on every attach added a commit per render and left a
native TimeInput showing a cleared rejection. The ref callback now sets
it only when the root differs from the committed one.

* perf(CheckboxInput): the disabled-message tooltip runs only while it can show

Every checkbox called useTooltip, though the tooltip shows only when the checkbox is disabled and has a disabledMessage. On 1,000 checkboxes at 6x CPU in Chromium, useTooltip and its hooks were about a fifth of render and commit. The tooltip now lives in a child component that mounts only while the message can show; it attaches to the row and the checkbox, and reports its description id for the input's aria-describedby (an empty id is left out).

* fix(CheckboxInput): the disabled reason describes the checkbox in the server markup

The reason renders once in a visually hidden element whose id the input names in aria-describedby during render, so it is there before hydration and before the tooltip mounts or shows (spec:AST-013 FR9; component:CheckboxInput FR4, FR6). The tooltip still mounts only while the reason can show; its text is hidden from assistive technology, so the reason describes the checkbox once. An SSR test checks the server markup and a clean hydration.

* fix(CheckboxInput): the disabled reason renders once

The visually hidden copy describes the input in the server markup and until the tooltip's text is in the document; then the tooltip describes it and the copy goes, so a disabled checkbox with a reason renders the text once, as on main. The changeset names the server-markup fix.

* fix(CheckboxInput): hand the description to the tooltip from its surface's own ref

useTooltip gains an internal onSurfaceMount callback, driven by the layer surface's ref, so CheckboxInput learns when the tooltip text is in the document without a document observer. The per-checkbox MutationObserver is gone.

* refactor(Tooltip): keep onSurfaceMount off the public TooltipOptions

The surface callback moves to useTooltipInternal(options, {onSurfaceMount}), which the package does not export. Public useTooltip calls it with no internal options, so TooltipOptions is unchanged. CheckboxInput imports the internal entry.

* fix(CheckboxInput): name the reason with an id the checkbox owns; no Tooltip change

The tooltip's text is a span with the id the input's aria-describedby names. While the server renders and the client hydrates, the tooltip layer has no markup, so a visually hidden copy carries that id instead (useIsHydrating). useTooltip is back to main: no internal entry and no surface callback.

* Merge main into #11916's branch

* Merge #12376's branch (8ef2015)

# Conflicts:
#	packages/core/src/CheckboxInput/CheckboxInput.test.tsx
#	packages/core/src/CheckboxInput/CheckboxInput.tsx

* Tooltip: describe the trigger with an in-place hidden copy of its text

The trigger's aria-describedby names a hidden copy (the hidden attribute)
of the tooltip text, rendered next to the trigger in server and client
markup. The post-hydration portal copy and its mount store are gone; the
id never changes. The shown tooltip's content is hidden from assistive
technology (except while pinned), so the text is read once.

Truncation tooltips (UndescribedTooltip) and a Button tooltip that repeats
the name render no copy, through TooltipDescribesContext in
Tooltip/tooltipPresentInterest. Group trailing-radius rules skip hidden
elements. InfoTip and Slider find the tooltip through a private helper.

* test(Layer): a disabled reason may describe its control from inside the tooltip

CheckboxInput names its own reason text, which sits inside the tooltip
after the first show. The touch-target helper now accepts an
aria-describedby id that resolves inside the reason's tooltip.

* Merge #12376's branch (9ae1d5c)

* test(Tooltip): browser evidence for AR1 in Chromium and WebKit

A story with a wrapped Button, an icon tooltip that adds to the name, one
that repeats it, and a cut label. The spec checks the hidden copy and the
accessible description before and after the first show, once, and no
description on the repeat and cut-label paths. AR1 gets a verification row.

* Tooltip: component content reaches the description; FR10, AR1 and FR2 as ruled

- Content that holds a component renders into the hidden copy through a
  portal, filled on the client, so its text reaches the description and a
  block never breaks a paragraph in server markup.
- The shown content is aria-hidden on every path except a pinned tooltip.
- CheckboxInput's own reason is a hidden span.
- ButtonGroup and InputGroup skip only the tooltip copy, not every hidden
  follower.
- FR10 drops aria-controls from the pinning button; AR1 names the pinned
  exception; FR2 records the element-child and component-content
  server-markup gap. The changeset and content JSDoc say content renders
  once from mount.
- The browser spec finds the cut label's tooltip by text.

* Tooltip: the copy joins text through getNodeText; docs name the hydration group

- Host markup becomes the copy's text through the shared getNodeText, which
  joins block lines with a space; textOf is gone.
- The Chromium binding's coverage check skips the row for a trigger
  described by the tooltip itself, which no Astryx state meets.
- The changeset names the components whose tooltips name the copy only
  after hydration.
- The CustomToggleTrigger story drops aria-controls, as FR10 does.
- ButtonGroup.doc.mjs leaves the diff (formatting only).

* Merge main into lane4/tooltip-mount-on-first-intent

# Conflicts:
#	packages/core/src/CheckboxInput/CheckboxInput.test.tsx
#	packages/core/src/CheckboxInput/CheckboxInput.tsx
#	packages/core/src/Layer/touchTriggerTargets.test.tsx

* Merge remote-tracking branch 'origin/main' into lane4/tooltip-mount-on-first-intent

# Conflicts:
#	docs/specs/components/Tooltip/Tooltip.spec.md

* test(Tooltip): read the shown surface and the description copy as the first-show mount draws them

* fix(Tooltip): the trigger's description is the hidden copy only until the layer mounts, then the tooltip's content

* test(Tooltip): the trigger reads its description from the tooltip's content once it mounts

* docs(Tooltip): describedBy names the copy until the first show, then the content; AR6 drops aria-controls as FR10 does

* fix(Tooltip): the description's host reaches render through a store, not state; CheckboxInput drops a fragment

* refactor(Tooltip): description id helpers live with the trigger contracts, so a Button swizzle carries no tooltip runtime

* fix(Button): a caller's mounted tooltip content counts as its tooltip; the description host uses the shared store factory

* Merge main into lane4/tooltip-mount-on-first-intent

Resolves Button.tsx and useTooltip.tsx against #12443 and #11831's line: the cut label's tooltip comes from main's lazy cutText module, and its caller-tooltip check (now in cutText.tsx) also counts a description's hidden copy and mounted tooltip content. useTooltip keeps lazyMount, keepsMountAfterShow and main's getInvoker. SideNav's labelTooltipOf finds the tooltip through the trigger's description.

* test(Text, TextInput): main's new tooltip cases read the tooltip a first interaction mounts

* test(Selector, MultiSelector, Tooltip): RTL status tooltips read the shown tooltip; the coverage check skips the tooltip-described row only while every state describes with a copy

* test(cli): overlays come before progress-bar-track in the unreached list, a part main's themes still leave there

* test: TooltipDescription joins the Firefox hover specs; the Tooltip binding audit stays Chromium-only (DevTools protocol); prettier

* Merge remote-tracking branch 'origin/main' into lane4/tooltip-mount-on-first-intent

# Conflicts:
#	packages/core/src/Text/Text.test.tsx
#	packages/core/src/Tooltip/Tooltip.tsx

* test(Text): the truncation tooltip's mount reads its layer marker, since it adds no description (#12653) and its layer mounts at the first show

* docs(useTooltip): the hook's JSDoc sits on the hook again, not on TooltipDescription

* fix(ButtonGroup, InputGroup): the trailing edge skips a tooltip's description by its own private marker, so a caller's hidden element whose id ends in -description still counts as a member

* test: checks that read a closed tooltip's layer read its first show or its description inside it; the corner tests compile the trailing-edge owner too

* fix(Button): a cut label described by the caller's own -description element still shows on keyboard focus; tests hover named controls and count the new corner cases

* Merge remote-tracking branch 'origin/main' into lane4/tooltip-mount-on-first-intent

# Conflicts:
#	docs/specs/components/Tooltip/Tooltip.spec.md
#	packages/core/src/CheckboxInput/CheckboxInput.test.tsx
#	packages/core/src/CheckboxList/CheckboxList.test.tsx
#	packages/core/src/PowerSearch/PowerSearch.test.tsx
#	packages/core/src/RadioList/RadioList.test.tsx
#	packages/core/src/SegmentedControl/SegmentedControl.test.tsx
#	packages/core/src/Slider/Slider.test.tsx
#	packages/core/src/Switch/Switch.test.tsx
#	packages/core/src/Tokenizer/Tokenizer.test.tsx
#	packages/core/src/Tooltip/useTooltip.tsx

* test(Tooltip): hover tests send the move a browser sends with the arrival (#11831), and read the mount marker before a show

* test(Timestamp, RichTextEditor): hover tests send the move that follows the arrival

* test(Tooltip): the hidden copy reads inline markup as it renders

* Merge remote-tracking branch 'origin/main' into lane4/tooltip-mount-on-first-intent

* chore: comment-provenance baseline drops the Button and InputGroup citations this PR removed

* Merge remote-tracking branch 'origin/main' into lane4/tooltip-mount-on-first-intent

This branch was successfully deployed

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

Labels

CLA Signed This label is managed by the Meta Open Source bot. lane:3 Astryx fix-loop lane 3 owns this

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant