Skip to content

perf(ToggleButton): a standalone toggle reads its group without loading the group's press tracking - #12150

Merged
cixzhang merged 4 commits into
mainfrom
perf/togglebutton-group-context-leaf
Nov 25, 2026
Merged

cixzhang merged 4 commits into
mainfrom
perf/togglebutton-group-context-leaf

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Primary intent

Performance fix: a page that renders ToggleButton without ToggleButtonGroup no longer loads the group's press tracking and the touch runtime behind it.

User impact

  • People loading a page with a standalone ToggleButton (a bold/italic toggle, a mute button): that page's first-load JavaScript drops by 0.4 to 1.5 KB gzip, depending on the bundler (table below), so the page no longer loads the group's code. No first-paint claim: a consumer's bytes also depend on its own bundler and chunks.
  • Toggle buttons in a group: unchanged; the group still tracks a press across its toggles under a finger or a pen.
  • Builders: no API change.

Cause

ToggleButton.tsx had two static imports that reached the group's press tracking:

  • GROUP_PRESS_POINTERS from hooks/useGroupPressTracking;
  • useToggleButtonGroup from ToggleButtonGroup.tsx, which imports useGroupPressTracking itself.

That brought the group module, its press tracking and the gesture code behind it onto every standalone toggle's page, which is above INV10's 0.3 KB allowance in every bundler measured (architecture:component-import-boundaries INV10).

Change

  • GROUP_PRESS_POINTERS: moves to hooks/pressGroupContext.ts, beside PressGroupContext, whose value it is. useGroupPressTracking imports and re-exports it, so AlertDialog and ButtonGroup keep their imports.
  • New ToggleButton/ToggleButtonGroupContext.ts: holds the group's context, its value type and useToggleButtonGroup. ToggleButtonGroup provides it; ToggleButton reads it.
  • No behavior change and no new press path.

Authority

architecture:component-import-boundaries INV10: an optional feature (here, group press tracking) costs nothing where it's unused.

Evidence

  • First-load JS gzip by bundler (production builds of the built package, React, React DOM and StyleX external; main → head):
Page Vite 8 Rolldown Rolldown, 64 KiB common chunks webpack 5
ToggleButton only 57.8 → 57.4 KB (−429 B) 57.1 → 56.7 KB (−440 B) 60.2 → 59.5 KB (−810 B) 59.9 → 58.5 KB (−1,472 B)
Button only +0 B +0 B +0 B +6 B
docs +0 B +0 B +0 B +4 B
form +0 B +0 B +0 B +16 B
  • Static import graph, ToggleButton only (built Core): 210 → 175 modules, depth 10 → 10. pnpm size:pages, which bundles with esbuild, reports 89,023 → 61,905 B gzip for that page. The production bundlers above already dropped most of those modules, so the user-facing figure is theirs.
  • Tests: ToggleButton, ButtonGroup and AlertDialog suites plus scripts/shared-identity.test.mjs: 256 of 256 pass. tsc and eslint clean.
  • Follow-up: once this is on main, a "Must not reach" row for a standalone ToggleButton (hooks/useGroupPressTracking) can pin it. The record adds a row only when it holds on main.

Owner and land path

  • Owner: Astryx maintainers, fix-loop lane 1.
  • Land path: code review, CI, merge.

Overlap checked: #11205 (it changes how group press tracking grows touch targets; this only moves a constant and the group context out of the tracking import edge. Whichever lands second merges main)

…ng the group's press tracking

ToggleButton imported GROUP_PRESS_POINTERS from useGroupPressTracking and
useToggleButtonGroup from ToggleButtonGroup, which imports that hook. So a
page with ToggleButton alone loaded the group's press tracking and the touch
runtime behind it.

GROUP_PRESS_POINTERS now lives in pressGroupContext, beside the context
whose value it is; useGroupPressTracking re-exports it. The group's context
and useToggleButtonGroup move to ToggleButtonGroupContext, which
ToggleButtonGroup provides and ToggleButton reads. No public API changes.

ToggleButton-only page: 89,023 -> 61,905 B gzip. Reference pages +5 B at
most.
@vercel

vercel Bot commented Nov 16, 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 25, 2026 6:31pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 25, 2026, 7:34 PM UTC

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

Copy link
Copy Markdown
Contributor Author

/approve-spec 86f0d57

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 4d55e1f

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
AlertDialog 136.7 kB (+10 B) · 16.4 kB CSS (0) — — · — · —
ButtonGroup 45.2 kB (+4 B) · 3.7 kB CSS (0) — — · — · —
MobileNavToggle 71.7 kB (+3 B) · 11.9 kB CSS (0) — — · — · —
84 more components
Component Size LoC Visual · A11y · RTL
TableCell 111.2 kB (+3 B) · 20.5 kB CSS (0) — — · — · —
BreadcrumbItem 106.5 kB (+2 B) · 14.3 kB CSS (0) — — · — · —
MobileNav 82.3 kB (+2 B) · 11.9 kB CSS (0) — — · — · —
NumberInput 108.8 kB (+2 B) · 13.2 kB CSS (0) — — · — · —
ChatComposerTokenElement 91.0 kB (+1 B) · 12.7 kB CSS (0) — — · — · —
ChatDictationButton 70.4 kB (+1 B) · 11.3 kB CSS (0) — — · — · —
IconButton 69.8 kB (+1 B) · 11.3 kB CSS (0) — — · — · —
Stepper 71.6 kB (+1 B) · 11.4 kB CSS (0) — — · — · —
TableHeaderCell 111.1 kB (+1 B) · 20.3 kB CSS (0) — — · — · —
lab/CommentComposer 190.7 kB (+1 B) · 1.9 kB CSS (0) — — · — · —
BaseTypeahead 87.0 kB (0) · 12.3 kB CSS (0) — — · — · —
Button 69.8 kB (0) · 11.3 kB CSS (0) — — · — · —
Calendar 81.1 kB (0) · 11.9 kB CSS (0) — — · — · —
Carousel 80.6 kB (0) · 12.3 kB CSS (0) — — · — · —
ChatComposer 93.9 kB (0) · 13.7 kB CSS (0) — — · — · —
ChatComposerInput 91.0 kB (0) · 12.7 kB CSS (0) — — · — · —
ChatLayout 93.6 kB (0) · 11.8 kB CSS (0) — — · — · —
ChatLayoutScrollButton 70.4 kB (0) · 11.4 kB CSS (0) — — · — · —
ChatSendButton 70.3 kB (0) · 11.3 kB CSS (0) — — · — · —
CodeBlock 86.0 kB (0) · 13.0 kB CSS (0) — — · — · —
ComplexSelector 86.9 kB (0) · 13.4 kB CSS (0) — — · — · —
DateInput 212.8 kB (0) · 19.1 kB CSS (0) — — · — · —
DateRangeInput 109.6 kB (0) · 14.4 kB CSS (0) — — · — · —
DrawerHeader 73.3 kB (0) · 14.4 kB CSS (0) — — · — · —
FileInput 80.0 kB (0) · 12.9 kB CSS (0) — — · — · —
Lightbox 153.8 kB (0) · 12.4 kB CSS (0) — — · — · —
Markdown 214.3 kB (0) · 23.8 kB CSS (0) — — · — · —
MoreMenu 137.3 kB (0) · 20.1 kB CSS (0) — — · — · —
MultiSelector 108.0 kB (0) · 19.1 kB CSS (0) — — · — · —
Pagination 153.6 kB (0) · 20.3 kB CSS (0) — — · — · —
Popover 108.5 kB (0) · 15.7 kB CSS (0) — — · — · —
Selector 120.4 kB (0) · 20.0 kB CSS (0) — — · — · —
SideNavHeading 91.5 kB (0) · 12.7 kB CSS (0) — — · — · —
SideNavItem 85.6 kB (0) · 12.5 kB CSS (0) — — · — · —
Table 129.5 kB (0) · 21.5 kB CSS (0) — — · — · —
TableSelectionToolbar 80.4 kB (0) · 14.7 kB CSS (0) — — · — · —
Thumbnail 74.4 kB (0) · 12.8 kB CSS (0) — — · — · —
Timestamp 28.5 kB (0) · 11.5 kB CSS (0) — — · — · —
Toast 109.9 kB (0) · 11.6 kB CSS (0) — — · — · —
ToggleButtonGroup 42.5 kB (0) · 3.7 kB CSS (0) — ✓ · ✓ · ✓
Tokenizer 116.8 kB (0) · 22.1 kB CSS (0) — — · — · —
TopNavHeading 91.3 kB (0) · 12.6 kB CSS (0) — — · — · —
TopNavMegaMenu 84.8 kB (0) · 13.3 kB CSS (0) — — · — · —
TopNavMenu 90.7 kB (0) · 12.6 kB CSS (0) — — · — · —
Typeahead 98.6 kB (0) · 14.6 kB CSS (0) — — · — · —
lab/ChatEmojiPicker 132.1 kB (0) · 773 B CSS (0) — — · — · —
lab/ChatReactionBar 133.3 kB (0) · 1.1 kB CSS (0) — — · — · —
lab/DiffViewer 99.0 kB (0) · 2.3 kB CSS (0) — — · — · —
lab/EmojiPicker 123.6 kB (0) · 751 B CSS (0) — — · — · —
lab/ListInput 100.5 kB (0) · 1.3 kB CSS (0) — — · — · —
lab/TransferList 143.4 kB (0) · 1.4 kB CSS (0) — — · — · —
lab/TransferListSelector 155.7 kB (0) · 1.6 kB CSS (0) — — · — · —
richtext/RichTextEditor 313.4 kB (0) · 2.7 kB CSS (0) — — · — · —
richtext/RichTextView 290.1 kB (0) · 2.4 kB CSS (0) — — · — · —
AppShell 94.1 kB (−1 B) · 15.1 kB CSS (0) — — · — · —
Banner 71.9 kB (−1 B) · 11.8 kB CSS (0) — — · — · —
ContextMenu 110.1 kB (−1 B) · 19.9 kB CSS (0) — — · — · —
DialogHeader 73.1 kB (−1 B) · 13.0 kB CSS (0) — — · — · —
DropdownMenu 137.1 kB (−1 B) · 20.1 kB CSS (0) — — · — · —
SideNav 118.2 kB (−1 B) · 12.7 kB CSS (0) — — · — · —
SideNavCollapseButton 70.7 kB (−1 B) · 11.3 kB CSS (0) — — · — · —
TabMenu 87.8 kB (−1 B) · 12.5 kB CSS (0) — — · — · —
PowerSearch 323.3 kB (−2 B) · 27.6 kB CSS (0) — — · — · —
TimeInput 184.6 kB (−2 B) · 18.0 kB CSS (0) — — · — · —
lab/DialogHeroHeader 94.5 kB (−2 B) · 372 B CSS (0) — — · — · —
DateTimeInput 236.7 kB (−3 B) · 20.8 kB CSS (0) — — · — · —
TextInput 103.8 kB (−4 B) · 13.0 kB CSS (0) — — · — · —
TopNav 73.4 kB (−5 B) · 12.2 kB CSS (0) — — · — · —
lab/TourStep 99.4 kB (−11 B) · 691 B CSS (0) — — · — · —
lab/Schedule 121.6 kB (−12 B) · 3.9 kB CSS (0) — — · — · —
lab/Comments 394.1 kB (−975 B) · 2.5 kB CSS (0) — — · — · —
lab/CommentThread 387.2 kB (−1.1 kB) · 2.4 kB CSS (0) — — · — · —
lab/VideoPlayer 237.0 kB (−3.7 kB) · 2.1 kB CSS (0) — — · — · —
lab/AudioPlayer 239.1 kB (−3.7 kB) · 1.8 kB CSS (0) — — · — · —
lab/MediaVolume 228.7 kB (−4.1 kB) · 1.5 kB CSS (0) — — · — · —
lab/MediaPlaybackRate 228.7 kB (−4.1 kB) · 1.5 kB CSS (0) — — · — · —
lab/MediaFullscreenButton 228.7 kB (−4.1 kB) · 1.5 kB CSS (0) — — · — · —
lab/MediaSeekButton 228.7 kB (−4.1 kB) · 1.5 kB CSS (0) — — · — · —
lab/MediaTimeSlider 228.7 kB (−4.1 kB) · 1.5 kB CSS (0) — — · — · —
lab/MediaCaptionsButton 228.7 kB (−4.1 kB) · 1.5 kB CSS (0) — — · — · —
lab/MediaPlayButton 228.7 kB (−4.1 kB) · 1.5 kB CSS (0) — — · — · —
lab/MediaTime 228.7 kB (−4.2 kB) · 1.5 kB CSS (0) — — · — · —
richtext/RichTextEditorToolbar 296.9 kB (−23.5 kB) · 454 B CSS (0) — — · — · —
ToggleButton 70.5 kB (−26.9 kB) · 11.3 kB CSS (−45 B) — ✓ · ✓ · —

Package size: @astryxdesign/core 8.06 MB packed (+517 B); no new dependencies.

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


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved pending CI: CI has not run on this head yet, because the pull request is a draft; it runs once the pull request is marked ready for review.

A standalone ToggleButton page measured 27,137 B gzip lighter here, with minified sizes matching your table exactly, while the four reference pages moved by at most 3 B and the ToggleButton, ButtonGroup and AlertDialog suites pass. No blocking findings. Once this is on main, the "Must not reach" row you mention will keep the split from regressing.

Claims and files checked

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

Claims:

  • Changeset: a page with a standalone ToggleButton no longer loads the group's press tracking or the touch runtime. Verified: the head page's bundle holds no tracking or gesture module (ToggleButton.tsx:29-35).
  • Changeset: that page drops about 26.5 KB gzip. Verified: 27,137 B measured.
  • Changeset: toggle buttons in a group behave the same. Verified: ToggleButtonGroup.tsx:29 still runs the tracking, and the group tracking tests pass.
  • Description: first-load JavaScript drops from 89,023 to 61,905 B gzip (−30%). Verified: minified sizes match exactly; gzip here goes from 89,279 to 62,142 B (−27,137, −30%), since local gzip differs by a few hundred bytes.
  • Description: the four reference pages change by +5, −1, 0 and −4 B gzip. Verified within a few bytes: +0, −1, +0 and −3 here, with minified sizes unchanged.
  • Description: two static imports caused it. Verified: base ToggleButton.tsx:33 and :35, and base ToggleButtonGroup.tsx:37.
  • Description: the tracking hook brings the action-group tracker, the touch hit area and the touch runtime. Verified: useGroupPressTracking.ts:22-37, and the base page bundles 13 gesture modules.
  • Description: the constant moves beside the press-group context and is re-exported, so AlertDialog and ButtonGroup keep their imports. Verified: pressGroupContext.ts:30, useGroupPressTracking.ts:25 and :125.
  • Description: the new context module holds the context, its type and the hook; the group provides it and the toggle reads it. Verified: ToggleButtonGroupContext.ts:18-45, ToggleButtonGroup.tsx:35, ToggleButton.tsx:35.
  • Description: no behavior change, no new press path and no API change. Verified: the built public surfaces are identical, and the behavior suites pass.
  • Description: the named suites pass, and tsc and eslint are clean. Verified: 263 tests across those suites and Button's hit-area suite pass; typecheck and lint are clean.
  • Description: the overlapping open pull request touches the same group press tracking. Verified: it edits the same four source files.

Files:

  • .changeset/togglebutton-group-tracking-first-load.md: clear
  • packages/core/src/ToggleButton/ToggleButton.tsx: clear
  • packages/core/src/ToggleButton/ToggleButtonGroup.tsx: clear
  • packages/core/src/ToggleButton/ToggleButtonGroupContext.ts: clear
  • packages/core/src/hooks/pressGroupContext.ts: clear
  • packages/core/src/hooks/useGroupPressTracking.ts: clear

Automated review (maintainer link)

…n bundlers

The changeset now states the first-load saving measured with Vite,
Rolldown and webpack on a ToggleButton-only page (0.4 to 1.5 KB gzip),
not the size report's esbuild figure.
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 6254623

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved pending CI: CI has not run on this head yet, because the pull request is a draft; it runs once the pull request is marked ready for review.

The corrected changeset holds: a standalone ToggleButton page measured 1,141 B gzip lighter with Vite 8, 1,093 B with Rolldown and 417 B with Rolldown and a 64 KiB common chunk, and its first-load chunks no longer hold the group, its tracking or any gesture module. The docs, form, menu and table reference pages did not grow, and the ToggleButton, ButtonGroup and AlertDialog suites pass (256 of 256). No blocking findings.

  • Non-blocking: the description's per-bundler table lists docs and form but not the menu and table reference pages that the import-boundaries record asks for when a shared module grows; both measured +0 B here, so adding the two rows completes the report.
Claims and files checked

Review mode: incremental; reason: none

changed rules (0): none

Claims:

  • Changeset: a standalone ToggleButton page no longer loads the group, its press tracking or the gesture code. Verified: the head page's first-load chunks hold none of those modules in Vite, Rolldown or the size report (ToggleButton.tsx:29-35).
  • Changeset: that page's first-load JavaScript drops 0.4 to 1.5 KB gzip, depending on the bundler. Verified: 1,141 B (Vite 8), 1,093 B (Rolldown) and 417 B (Rolldown with a 64 KiB common chunk); webpack was not reproduced here.
  • Changeset: toggle buttons in a group behave the same. Verified: ToggleButtonGroup.tsx:29 still runs the tracking, and the group tracking suites pass.
  • Description: two static imports caused it. Verified: base ToggleButton.tsx:33 and :35, and base ToggleButtonGroup.tsx:37.
  • Description: that cost was above the 0.3 KB allowance in every bundler measured. Verified: 417 to 1,141 B here.
  • Description: the constant moves beside the press-group context and the tracking hook re-exports it, so the alert dialog and button group keep their imports. Verified: pressGroupContext.ts:30, useGroupPressTracking.ts:25 and :125, AlertDialog.tsx:48, ButtonGroup.tsx:33-36.
  • Description: the new context module holds the context, its type and the hook; the group provides it and the toggle reads it. Verified: ToggleButtonGroupContext.ts:18-45, ToggleButtonGroup.tsx:35, ToggleButton.tsx:35.
  • Description: no behavior change, no new press path and no API change. Verified: the built public surfaces are identical, and the behavior suites pass.
  • Description: the per-bundler table for the ToggleButton, Button, docs and form pages. Verified in range: the ToggleButton figures here differ from the table's (its page setup is not stated) but stay within 0.4 to 1.5 KB; Button, docs and form are +0 B in Vite and Rolldown; webpack was not reproduced.
  • Description: the ToggleButton page's static import graph goes from 210 to 175 modules at the same depth. Verified: 205 to 170 Core modules plus the same 5 external packages, depth unchanged.
  • Description: the size report gives 89,023 to 61,905 B gzip for that page. Verified: minified sizes match; gzip here goes from 89,279 to 62,142 B (−27,137 against −27,118), within local gzip variation.
  • Description: the named suites pass 256 of 256, and tsc and eslint are clean. Verified: 256 of 256 pass, and typecheck and eslint are clean.
  • Description: the overlapping open pull request touches the same group press tracking. Verified: it edits the same four source files.

Files:

  • .changeset/togglebutton-group-tracking-first-load.md: clear
  • packages/core/src/ToggleButton/ToggleButton.tsx: clear
  • packages/core/src/ToggleButton/ToggleButtonGroup.tsx: clear
  • packages/core/src/ToggleButton/ToggleButtonGroupContext.ts: clear
  • packages/core/src/hooks/pressGroupContext.ts: clear
  • packages/core/src/hooks/useGroupPressTracking.ts: clear

Automated review (maintainer link)

# Conflicts:
#	packages/core/src/hooks/useGroupPressTracking.ts
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec fe9eb9e

@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: CI passed on this head, and there are no blocking findings.

A standalone ToggleButton page no longer loads the group's press tracking: it measured 1,100 B gzip lighter with Vite 8, 1,080 B with Rolldown and 429 B with Rolldown and a 64 KiB common chunk, while the docs, form, menu and table reference pages did not grow and grouped toggles behave as before.

  • Non-blocking: the description's per-bundler table lists docs and form but not the menu and table reference pages that the import-boundaries record asks for when a shared module grows; both measured +0 B here, so adding the two rows completes the report.
Claims and files checked

Review mode: same-head; reason: none

Claims:

  • Changeset: a standalone ToggleButton page no longer loads the group, its press tracking or the gesture code. Verified: the head page's first-load chunks hold none of those modules in Vite, Rolldown or the size report (ToggleButton.tsx:29-35).
  • Changeset: that page's first-load JavaScript drops 0.4 to 1.5 KB gzip, depending on the bundler. Verified for Vite and Rolldown: 1,100 B (Vite 8), 1,080 B (Rolldown) and 429 B (Rolldown with a 64 KiB common chunk); the webpack figure could not be reproduced here.
  • Changeset: toggle buttons in a group behave the same. Verified: ToggleButtonGroup.tsx:235 still runs the tracking and :244 provides the same context, and the group tracking suites pass.
  • Description: two static imports caused it. Verified: base ToggleButton.tsx:33 and :35, and base ToggleButtonGroup.tsx:37.
  • Description: that cost was above the 0.3 KB allowance in every bundler measured. Verified: 429 to 1,100 B here.
  • Description: the constant moves beside the press-group context and the tracking hook re-exports it, so the alert dialog and button group keep their imports. Verified: pressGroupContext.ts:30, useGroupPressTracking.ts:25 and :125, AlertDialog.tsx:53, ButtonGroup.tsx:33-36; the internal touch entry keeps the same binding (internal/touch.ts:133-135).
  • Description: the new context module holds the context, its type and the hook; the group provides it and the toggle reads it. Verified: ToggleButtonGroupContext.ts:18-45, ToggleButtonGroup.tsx:35 and :244, ToggleButton.tsx:35.
  • Description: no behavior change, no new press path and no API change. Verified: the built public surfaces are identical, the behavior suites pass, and CI's visual report shows the toggle's shots unchanged.
  • Description: the per-bundler table for the ToggleButton, Button, docs and form pages. Verified in range: the ToggleButton figures here differ from the table's (its page setup is not stated) but stay within 0.4 to 1.5 KB; Button, docs and form are +0 B in Vite and Rolldown; webpack was not reproduced.
  • Description: the ToggleButton page's static import graph goes from 210 to 175 modules at the same depth. Verified: 212 to 176 at this head, where the merged base has two more modules; depth unchanged.
  • Description: the size report gives 89,023 to 61,905 B gzip for that page. Verified in substance: 91,703 to 64,464 B at this head (−27,239 against −27,118), on the larger merged base.
  • Description: the named suites pass 256 of 256, and tsc and eslint are clean. Verified: the same suites hold 260 tests after the merge, all passing, and typecheck and eslint are clean.
  • Description: a guard row for a standalone ToggleButton can follow once this is on the main branch. Verified: the import-boundaries record adds a row only once it holds on the main branch.
  • Description: the overlapping open pull request changes how group press tracking grows touch targets. Verified: it is open and edits the same four source files.

Files:

  • .changeset/togglebutton-group-tracking-first-load.md: clear
  • packages/core/src/ToggleButton/ToggleButton.tsx: clear
  • packages/core/src/ToggleButton/ToggleButtonGroup.tsx: clear
  • packages/core/src/ToggleButton/ToggleButtonGroupContext.ts: clear
  • packages/core/src/hooks/pressGroupContext.ts: clear
  • packages/core/src/hooks/useGroupPressTracking.ts: clear, including the merge's resolution of its header

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as ready for review November 20, 2026 13:37
@cixzhang cixzhang added the lane:1 Astryx fix-loop lane 1 owns this label Nov 21, 2026
@cixzhang cixzhang added the ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) label Nov 25, 2026
@cixzhang
cixzhang marked this pull request as draft November 25, 2026 18:11
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 4d55e1f

@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 running on this head and has not finished yet.

A standalone ToggleButton page no longer imports the group, its press tracking or the gesture modules, grouped toggles keep the same tracking, and no public API changes. No blocking findings.

  • Non-blocking: the description's per-bundler table lists docs and form but not the menu and table reference pages that the import-boundaries record asks for when a shared module grows; adding them completes the report.
  • Non-blocking: the Evidence figures predate the latest merges of main. The ToggleButton page's import graph is now 205 → 169 modules rather than 210 → 175, with the same drop and depth, so refreshing the section at the final head keeps it accurate.
Claims and files checked

Review mode: same-head; reason: none

Changed rules (0): none since the last review at this head.

Claims:

  • Changeset: a standalone ToggleButton page no longer loads the group, its press tracking or the gesture code. Verified: this head's import graph from ToggleButton.tsx reaches none of them; the base reaches the group, three tracking hooks and 14 gesture modules.
  • Changeset: that page's first-load JavaScript drops 0.4 to 1.5 KB gzip, depending on the bundler. Consistent: this patch measured 429 to 1,100 B in Vite and Rolldown on an earlier base, and the base and head import graphs at this head differ by the same modules; webpack was not reproduced.
  • Changeset: toggle buttons in a group behave the same. Verified: ToggleButtonGroup.tsx:229, :235 and :244; ToggleButton.tsx:374-380.
  • Description: the standalone page saving and the unchanged grouped toggles. Verified as above.
  • Description: no API change for builders. Verified: ToggleButton/index.ts and hooks/index.ts are unchanged, and the new module is imported only from its own folder.
  • Description: two static imports caused the cost. Verified: base ToggleButton.tsx:33 and :35, and base ToggleButtonGroup.tsx:37.
  • Description: that cost was above the 0.3 KB allowance in every bundler measured. Verified for Vite and Rolldown on this patch: 429 to 1,100 B.
  • Description: the constant moves beside the press-group context and the tracking hook re-exports it, so the alert dialog and button group keep their imports. Verified: pressGroupContext.ts:30, useGroupPressTracking.ts:25 and :125, AlertDialog.tsx:54, ButtonGroup.tsx:33-36.
  • Description: the new context module holds the context, its type and the hook; the group provides it and the toggle reads it. Verified: ToggleButtonGroupContext.ts:18-45, ToggleButtonGroup.tsx:35 and :244, ToggleButton.tsx:35.
  • Description: no behavior change and no new press path. Verified: the context and constant move verbatim, and the toggle's pointer choice is unchanged (ToggleButton.tsx:374-380).
  • Description: the import-boundaries rule on optional features is the authority. Verified: it covers this change.
  • Description: the per-bundler table for the ToggleButton, Button, docs and form pages. Verified in range: Button, docs and form measured +0 B in Vite and Rolldown on this patch, and the reference pages' module sets are unchanged at this head; webpack was not reproduced; the menu and table rows are missing (note above).
  • Description: the ToggleButton page's import graph goes from 210 to 175 modules at the same depth. Verified in substance: 205 to 169 at this head, the same drop (note above).
  • Description: the size report shows the ToggleButton page about 27 KB lighter. Consistent: earlier runs on this patch measured 27,137 and 27,239 B; not re-measured at this head.
  • Description: the ToggleButton, ButtonGroup and AlertDialog suites and the shared-identity test pass, and typecheck and lint are clean. Verified: typecheck and lint pass at this head, and the suites passed on this patch at an earlier head; the unit test shards are still running here.
  • Description: the overlap with #11205. Verified: that open draft edits four of the same source files.
  • Description: a "Must not reach" row follows once this is on main. A plan; nothing to check yet.

Files:

  • .changeset/togglebutton-group-tracking-first-load.md: clear (patch release note; claims checked above).
  • packages/core/src/ToggleButton/ToggleButton.tsx: clear (two imports move; no logic change).
  • packages/core/src/ToggleButton/ToggleButtonGroup.tsx: clear (provides the moved context; tracking unchanged).
  • packages/core/src/ToggleButton/ToggleButtonGroupContext.ts: clear (verbatim move with exports; same shared key; private to its folder).
  • packages/core/src/hooks/pressGroupContext.ts: clear (one new constant; header updated).
  • packages/core/src/hooks/useGroupPressTracking.ts: clear (imports and re-exports the same binding; header updated).

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as ready for review November 25, 2026 19:10
@cixzhang
cixzhang merged commit 0dda082 into main Nov 25, 2026
162 checks passed
@github-actions
github-actions Bot deleted the perf/togglebutton-group-context-leaf branch November 26, 2026 06:04

This branch was successfully deployed

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

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant