Repository navigation
perf(ToggleButton): a standalone toggle reads its group without loading the group's press tracking - #12150
Conversation
…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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec 86f0d57 |
PR Analysis Report🔎 Preview ·
|
| 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
There was a problem hiding this comment.
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:29still 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:33and:35, and baseToggleButtonGroup.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:25and: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: clearpackages/core/src/ToggleButton/ToggleButton.tsx: clearpackages/core/src/ToggleButton/ToggleButtonGroup.tsx: clearpackages/core/src/ToggleButton/ToggleButtonGroupContext.ts: clearpackages/core/src/hooks/pressGroupContext.ts: clearpackages/core/src/hooks/useGroupPressTracking.ts: clear
…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.
|
/approve-spec 6254623 |
There was a problem hiding this comment.
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:29still runs the tracking, and the group tracking suites pass. - Description: two static imports caused it. Verified: base
ToggleButton.tsx:33and:35, and baseToggleButtonGroup.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:25and: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: clearpackages/core/src/ToggleButton/ToggleButton.tsx: clearpackages/core/src/ToggleButton/ToggleButtonGroup.tsx: clearpackages/core/src/ToggleButton/ToggleButtonGroupContext.ts: clearpackages/core/src/hooks/pressGroupContext.ts: clearpackages/core/src/hooks/useGroupPressTracking.ts: clear
# Conflicts: # packages/core/src/hooks/useGroupPressTracking.ts
|
/approve-spec fe9eb9e |
There was a problem hiding this comment.
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:235still runs the tracking and:244provides the same context, and the group tracking suites pass. - Description: two static imports caused it. Verified: base
ToggleButton.tsx:33and:35, and baseToggleButtonGroup.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:25and: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:35and: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: clearpackages/core/src/ToggleButton/ToggleButton.tsx: clearpackages/core/src/ToggleButton/ToggleButtonGroup.tsx: clearpackages/core/src/ToggleButton/ToggleButtonGroupContext.ts: clearpackages/core/src/hooks/pressGroupContext.ts: clearpackages/core/src/hooks/useGroupPressTracking.ts: clear, including the merge's resolution of its header
|
/approve-spec 4d55e1f |
There was a problem hiding this comment.
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.tsxreaches 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,:235and: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.tsandhooks/index.tsare unchanged, and the new module is imported only from its own folder. - Description: two static imports caused the cost. Verified: base
ToggleButton.tsx:33and:35, and baseToggleButtonGroup.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:25and: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:35and: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).
Primary intent
Performance fix: a page that renders
ToggleButtonwithoutToggleButtonGroupno longer loads the group's press tracking and the touch runtime behind it.User impact
Cause
ToggleButton.tsxhad two static imports that reached the group's press tracking:GROUP_PRESS_POINTERSfromhooks/useGroupPressTracking;useToggleButtonGroupfromToggleButtonGroup.tsx, which importsuseGroupPressTrackingitself.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-boundariesINV10).Change
GROUP_PRESS_POINTERS: moves tohooks/pressGroupContext.ts, besidePressGroupContext, whose value it is.useGroupPressTrackingimports and re-exports it, so AlertDialog and ButtonGroup keep their imports.ToggleButton/ToggleButtonGroupContext.ts: holds the group's context, its value type anduseToggleButtonGroup.ToggleButtonGroupprovides it;ToggleButtonreads it.Authority
architecture:component-import-boundariesINV10: an optional feature (here, group press tracking) costs nothing where it's unused.Evidence
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.scripts/shared-identity.test.mjs: 256 of 256 pass.tscandeslintclean.hooks/useGroupPressTracking) can pin it. The record adds a row only when it holds on main.Owner and land path
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)