Repository navigation
perf(ContextMenu): load the touch sheet's action list only for the sheet presentation - #11616
Conversation
…eet presentation ContextMenu imported the sheet's action list (List, ListItem, the checkbox row, Field, Divider and List's layout-motion engine) statically, so every pointer menu, Table's cell menus included, carried it. ContextMenu now uses DropdownMenu's existing lazy sheet module: the frame and the action list load after mount, only while the menu resolves to the sheet, and the list preloads at rest so the first open shows its rows at once. A new test checks that a pointer menu loads no sheet action list (it fails on the previous code) and that a sheet menu still opens, drills into a sub-menu and comes back.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec af43da2 |
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| DropdownMenu | 106.1 kB (0) · 18.6 kB CSS (0) | — | ✗ · ✓ · ✓ |
| DropdownMenuCheckboxItem | 28.4 kB (0) · 7.1 kB CSS (0) | — | ✗ · ✓ · ✓ |
| DropdownMenuDivider | 5.3 kB (0) · 548 B CSS (0) | — | ✗ · ✓ · — |
14 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| DropdownMenuGroup | 6.4 kB (0) · 3.4 kB CSS (0) | — | ✗ · ✓ · — |
| DropdownMenuItem | 27.6 kB (0) · 6.8 kB CSS (0) | — | ✗ · ✓ · — |
| DropdownMenuRadioGroup | 6.6 kB (0) · 3.3 kB CSS (0) | — | ✗ · ✓ · — |
| DropdownMenuRadioItem | 28.5 kB (0) · 7.1 kB CSS (0) | — | ✗ · ✓ · — |
| DropdownMenuSubMenu | 79.0 kB (0) · 10.3 kB CSS (0) | — | ✗ · ✓ · ✓ |
| Markdown | 201.3 kB (+144 B) · 21.7 kB CSS (0) | — | — · — · — |
| MoreMenu | 106.4 kB (0) · 18.6 kB CSS (0) | — | — · — · — |
| ContextMenuItem | 35.1 kB (−1 B) · 6.9 kB CSS (0) | — | — · — · — |
| lab/CommentThread | 359.9 kB (−418 B) · 2.4 kB CSS (0) | — | — · — · — |
| lab/Comments | 366.9 kB (−655 B) · 2.5 kB CSS (0) | — | — · — · — |
| ContextMenu · Storybook | 100.7 kB (−19.0 kB) · 18.4 kB CSS (0) | 725 (+1) | ✓ · ✓ · ✓ |
| TableHeaderCell | 101.6 kB (−19.1 kB) · 18.7 kB CSS (0) | — | — · — · — |
| Table | 118.8 kB (−19.1 kB) · 19.4 kB CSS (0) | — | — · — · — |
| TableCell | 101.9 kB (−19.1 kB) · 18.9 kB CSS (0) | — | — · — · — |
Visual changes: 4 snapshots in 1 component
A change is a question for the reviewer, not a failure.
Package size: @astryxdesign/core 7.57 MB packed (+162 B); no new dependencies.
Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.
Generated by PR Enrichment workflow | View full report
…ts Effect; changeset wording
|
/approve-spec 4130c03 |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet, because the pull request is still a draft.
ContextMenu now takes its sheet frame and action list from DropdownMenu's lazy sheet module, so pointer menus and Table cell menus no longer ship the action list in the first load. The new sheet-loading test fails on main and passes here, the import-boundary check holds, and the Table and ContextMenu entries each drop about 19 KB gzip.
One optional cleanup: the two file headers this change edits (ContextMenu.tsx and lazyMenuBottomSheet.ts) run well past the roughly 12-line header guideline, so consider moving their explanatory paragraphs next to the code they describe.
Claims and files checked
- Claim: a pointer ContextMenu (the default presentation, and every Table cell menu) no longer carries the sheet's action list. Verified: the new pointer test fails on
mainwith one load and passes here; the default presentation ispopoverand Table's cell menu sets none. - Claim: ContextMenu now shares DropdownMenu's sheet module, which loads the sheet only for the sheet presentation. Verified: the new imports and the sheet-only render branch in
ContextMenu.tsx, and the preload gated on a data-driven sheet menu. - Claim: Table and ContextMenu pages load about 57 KB less JavaScript, about 20 KB gzip. Verified for gzip (about 19 KB on both entry builds); the minified figure matches a build with StyleX compiled.
- Claim: a sheet menu still loads its sheet after mount and opens as before. Verified: the sheet test passes before and after the change, and the preload runs in an Effect.
- Claim: DropdownMenu already loads the same code through its lazy sheet module. Verified in
DropdownMenu.tsx. - Claim: no behavior change and no public API change. Verified: the API report lists no added, changed or removed entries, and 471 tests pass.
- Claim: no load moves to first open or to intent. Verified: pointer menus never load the list and sheet menus load it at mount.
- Claim: the sheet's back Button stays a static import. Verified in
ContextMenu.tsx. - Claim: the ContextMenu record gains one PR1 sentence, and its test list and FR10/PR1 row cite the new test. Verified in the record diff.
- Claim: the Table to ContextMenu boundary crossing remains and its cost drops. Verified: the check still lists it, at a lower cost.
- Claim: the boundary check prints Table's eager gzip falling by about 19 KB. Verified within local tolerance.
- Claim: the page-level size table for Table, ContextMenu, DropdownMenu and Markdown. Verified in direction and size; DropdownMenu is unchanged and Markdown grows by under 1 KB gzip.
- Claim: the pointer test fails on
mainand the sheet test passes on both. Verified. - Claim: the listed test run passes 18 files and 471 tests. Verified.
- Claim: typecheck, ESLint on the changed files, the knowledge check and the boundary check pass. Verified.
- Claim: an Android emulator long press opens the sheet and drills in on both sides. Stated by the author as emulator evidence; not rerun here.
- File
.changeset/contextmenu-pointer-no-sheet-code.md: clear. - File
docs/specs/components/ContextMenu/ContextMenu.spec.md: clear. - File
packages/core/src/ContextMenu/ContextMenu.sheetLoading.test.tsx: clear. - File
packages/core/src/ContextMenu/ContextMenu.tsx: clear, with the optional header suggestion. - File
packages/core/src/DropdownMenu/lazyMenuBottomSheet.ts: clear, with the optional header suggestion.
| * @file ContextMenu.tsx | ||
| * @input Uses React, StyleX, useLayer, shared layer dismissal, BottomSheet, | ||
| * useListFocus, and the shared menu-presentation resolver | ||
| * @input Uses React, StyleX, useLayer, shared layer dismissal, the lazily |
There was a problem hiding this comment.
Optional, non-blocking: this file header runs 39 lines (4-42), well past the roughly 12-line header guideline for source comments. Consider keeping @input, @output, @position and the SYNC: list here and moving the explanatory paragraphs beside the code they explain.
| * @output Exports MenuBottomSheet and MenuBottomSheetActionList wrappers that | ||
| * load the touch sheet on first render | ||
| * @position Internal to DropdownMenu | ||
| * @position Internal to DropdownMenu and ContextMenu |
There was a problem hiding this comment.
Optional, non-blocking: this header runs 23 lines (5-27), past the roughly 12-line header guideline. The hydration paragraph could sit beside the two wrappers it explains, leaving @input, @output and @position here.
|
/approve-spec 624a831 |
There was a problem hiding this comment.
Approved pending CI: test is still running on this head.
ContextMenu now takes its sheet frame and action list from DropdownMenu's lazy sheet module, so pointer menus and Table cell menus no longer ship the action list in the first load. The new sheet-loading test fails on main and passes here, and the menu and table reference pages each drop about 20 KB gzip with no public API change.
Optional cleanups:
- The two file headers this change edits (
ContextMenu.tsx, 39 lines, andlazyMenuBottomSheet.ts, 23 lines) still run past the roughly 12-line header guideline. - Miss: the first sentence of the new Effect note (
ContextMenu.tsx:394) runs 26 words over two topics; ending it after "presentation" keeps each sentence under the 25-word limit.
Claims and files checked
Review mode: same-head; reason: none
- Claim: a pointer ContextMenu (the default presentation, and every Table cell menu) no longer carries the sheet's action list. Verified: the new pointer test fails on
mainwith one load and passes here; Table's cell menu sets no presentation, so it takes thepopoverdefault. - Claim: ContextMenu now shares DropdownMenu's sheet module, which loads the sheet only for the sheet presentation. Verified: the new imports, the sheet-only render branch and the preload gated on a data-driven sheet menu in
ContextMenu.tsx. - Claim: pages with a Table or a ContextMenu load about 57 KB less JavaScript, about 20 KB gzip. Verified: about 57 KB minified and 20 to 21 KB gzip less on the table, menu and ContextMenu pages.
- Claim: a sheet menu still loads its sheet after mount and opens as before. Verified: the sheet test passes on
mainand here, and the preload runs in an Effect. - Claim: DropdownMenu already loads the same code through its lazy sheet module. Verified in
DropdownMenu.tsx. - Claim: no behavior change and no public API change. Verified: the API comparison lists no added, changed or removed entries, CI's API report for this head agrees, and 471 tests pass.
- Claim: no load moves to first open or to intent, so the import-boundary record's deferred-load rules are untouched. Verified: pointer menus never load the list and sheet menus load it at mount.
- Claim: the sheet's back Button stays a static import. Verified in
ContextMenu.tsx. - Claim: the ContextMenu record gains one PR1 sentence, and its test list and FR10/PR1 row cite the new test. Verified in the record diff.
- Claim: the Table to ContextMenu boundary crossing remains and its cost drops. Verified: the check still lists it, at about 67 KB instead of about 87 KB.
- Claim: the boundary check prints Table's eager gzip falling by about 19 KB. Verified: about 19.6 KB; the absolute sizes moved with
main. - Claim: the page-level size table for Table, ContextMenu, DropdownMenu and Markdown. Verified for Table, ContextMenu and DropdownMenu; the Markdown page changes by under 1 KB gzip.
- Claim: the pointer test fails on
mainand the sheet test passes on both. Verified. - Claim: the listed test run passes 18 files and 471 tests. Verified.
- Claim: typecheck, ESLint on the changed files, the knowledge check, the shared-identity check and the boundary check pass. Verified, and CI's typecheck and lint pass on this head.
- Claim: an Android emulator long press opens the sheet and drills in on both sides, and the take carries to this head. Stated by the author; it carries because the latest merge of
mainchanges none of this pull request's files and no Core source file. - File
.changeset/contextmenu-pointer-no-sheet-code.md: clear. - File
docs/specs/components/ContextMenu/ContextMenu.spec.md: clear. - File
packages/core/src/ContextMenu/ContextMenu.sheetLoading.test.tsx: clear. - File
packages/core/src/ContextMenu/ContextMenu.tsx: clear, with the optional header and comment notes. - File
packages/core/src/DropdownMenu/lazyMenuBottomSheet.ts: clear, with the optional header note. - Rule changed since the last review, the review mode line: checked this comment, no finding.
- Rule changed since the last review, same-head re-review: checked that this head is the last reviewed head, then the description, labels, approvals and conversation, no finding.
- Rule changed since the last review, how changed rules are established: checked the earlier and current review rules side by side (three rules changed), no finding.
| // Syncs the touch sheet's action list with the presentation: a data-driven | ||
| // sheet menu loads its rows at rest, so its first open shows them at once. A | ||
| // pointer menu never loads them. |
There was a problem hiding this comment.
Optional, non-blocking (missed in the earlier review): the first sentence here runs 26 words over two topics, past the 25-word limit for source-comment descriptions. Ending it after "presentation" fixes both:
| // Syncs the touch sheet's action list with the presentation: a data-driven | |
| // sheet menu loads its rows at rest, so its first open shows them at once. A | |
| // pointer menu never loads them. | |
| // Syncs the touch sheet's action list with the presentation. A data-driven | |
| // sheet menu loads its rows at rest, so its first open shows them at once. A | |
| // pointer menu never loads them. |












Primary intent
A pointer
ContextMenu, which is the default and is every Table cell menu, no longer loads the touch bottom sheet's action list.ContextMenuimported that list statically: List, ListItem, the checkbox row, Field, Divider and List's layout-animation engine. Every page with a context menu carried it, though only thebottom-sheetpresentation renders it.DropdownMenualready loads the same code through its lazy sheet module;ContextMenunow reuses that module. This is a performance change with no behavior change, which none of the narrower templates covers.User or maintainer impact
ContextMenu: about 57 KB less JavaScript before first paint (about 20 KB gzip).presentation="bottom-sheet", oradaptiveon a compact touch screen): unchanged. It loads its sheet frame and action list after mount, as its frame already did and asDropdownMenudoes. The list preloads at rest, so the first open shows its rows at once.Problem and solution fit
ContextMenuimportsMenuBottomSheet,MenuBottomSheetActionListandpreloadMenuBottomSheetActionListfrom the existingDropdownMenu/lazyMenuBottomSheet, and drops its own lazy sheet frame and its static action-list import.Button. Pages almost always render a Button anyway, so deferring it saves nothing at the app level.Authority
component:ContextMenuPR1: a sentence states that the sheet's code loads after mount and only while the menu resolves to the sheet.verified_byand the FR10/PR1 verification row cite the new test.architecture:component-import-boundariesDEC-1 and the owner's 11-10 "load with the page" answer are untouched: no load moves to first open or to intent.Table/tableContextMenu → ContextMenustill crosses; its CI cost drops. Removing that row is a separate decision.Change and evidence
Page-level first-load bytes
Base
90abc74eagainst this head. Core'ssrcwas compiled with its Babel config, with Core'ssideEffects. esbuild then built one app bundle per page: minified, ESM, code splitting on, bare imports external. First load is the entry chunk plus its static imports, with gzip at level 9.Behavior
ContextMenu.sheetLoading.test.tsxchecks that a pointer menu opens without loading the sheet's action list. It fails onmain(the list module loads once) and passes here. Its second case checks that a sheet menu opens with its rows, drills into a sub-menu and comes back with the back button. It passes on both.bottom-sheetContextMenu, built from base and from head, a real long press (adb shell input swipe, 900 ms) opens the sheet with its rows, and a tap on "Move to" drills in. Base and head behave the same; head was taken twice. Retaken after mergingmain(at 4d81c5e), sincemainhad changedContextMenu.tsx(the cursor anchor's base box): base wasmainat that point, and the result is the same. This head (624a831) mergesmainagain;mainchanged neitherContextMenu.tsxnorDropdownMenu/lazyMenuBottomSheet.tssince, so that take carries.Scope
Components: ContextMenu (and DropdownMenu's lazy sheet module header)
Writing rubric results
Record changed:
component:ContextMenu. PR1 gains one sentence: the touch sheet's code (its frame and its data-driven action list) loads after mount, and only while the menu resolves to the sheet presentation, so a pointer menu carries none of it.verified_byand the FR10/PR1 verification row add the new test.Testing
vitest run --project ui packages/core/src/ContextMenu packages/core/src/DropdownMenu packages/core/src/Table/tableContextMenu.test.tsx: 18 files, 471 tests pass.pnpm check:component-import-boundaries --base-ref origin/main: boundaries hold.pnpm -F @astryxdesign/core typecheck, ESLint on changed files,pnpm check:knowledge, shared-identity check: pass.