Repository navigation
Conversation
TableCell and TableHeaderCell imported `wrapInTableContextMenu` statically, so every table cell pulled in ContextMenu, DropdownMenu's menu hooks and the touch sheet, even in tables that never pass `contextMenuActions`. Plugins and the Table entry also imported `resolveContextActions` from the same module. - `tableContextActions.ts` holds the dependency-free helpers (`resolveContextActions`, `hasContextActions`). Plugins and the Table entry import from it; `tableContextMenu` re-exports `resolveContextActions` for existing imports. - `TableCellContextMenu` renders a cell's content as-is when it has no actions, and otherwise loads `TableContextMenu` with `React.lazy`, the pattern ContextMenu already uses for its touch sheet. While the menu loads, the content sits in a wrapper with the trigger's styles, so the cell's layout doesn't shift. - Tests: `TableCellContextMenu.test.tsx` checks the menu module is not imported for cells without actions and is for a cell with actions. Suites that right-click cells warm the lazy menu once in `beforeAll` (`warmTableContextMenu`, like `warmMenuBottomSheet`). Bundle (esbuild, minified, package source, React and StyleX external): the static closure of `TableCell`, `TableRow` and `TableBody` goes from 74,769 B to 7,207 B gzip; the menu becomes its own lazy chunk.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Moving the context menu out of the cell modules' static imports is a clear win for tables without actions, but this needs changes before it can land. The Suspense boundary in TableCellContextMenu wraps the cell's own children, so when the menu chunk loads every cell with actions remounts its content: keyboard focus on a sort control drops to the page and any state inside the cell resets, which keeping the children outside the suspending subtree (and a test for focus and state) would fix. Please also report base and head gzip sizes for the TableCell and TableHeaderCell imports plus the CSS delta, as the component size rule asks, and use the [perf] changeset category instead of [fix].
[Automated review]
humbertovirtudes
left a comment
There was a problem hiding this comment.
Requesting changes on exact head 70f7f1af921f77730990fe2518d2e7c7483faf06 for the Table-related delta and its direct dependencies. This is not a rejection of unrelated work in the PR.
The Suspense fallback owns one copy of caller children and the resolved lazy component owns another. Resolving the menu replaces the fallback subtree rather than preserving cell-content identity. This resets state and mount effects and can drop focus from a sortable header or editable body cell.
Failure case: On a cold route, render a cell with actions containing a stateful editor or a focused sort control. Enter text or focus the control while the chunk is pending; resolving the chunk mounts a new content subtree. This also affects a getter that will return an empty action list: getters still take the lazy path.
Requested fix: Keep the cell content and its trigger host outside the suspending subtree, and lazy-load only the menu behavior/surface through a stable seam. Add deferred-import tests that assert the same content node, retained input state, one mount, and retained focus for both body and header cells. Check keyboard context invocation, menu navigation and Escape focus return after resolution.
Validation boundary: these findings are grounded in the exact implementation and relevant tests. Isolated source/geometry probes are not fresh mounted React, browser, clipboard, screen-reader or native-device certification. Retain the applicable focused tests and head-bound evidence when updating the PR.
# Conflicts: # packages/core/src/Table/plugins/sortable/useTableSortable.tsx
The lazy menu used to wrap the cell's children inside its Suspense boundary, so when the menu arrived React replaced the fallback copy with a new one: focus inside the cell dropped to the page and the cell's state reset. The cell now renders the right-click trigger and its cursor anchor itself, and the menu loads beside them through ContextMenuForTrigger, an internal mode of ContextMenu that opens from a trigger its caller renders. The content's DOM node, focus and state survive the load; until the menu attaches, right-click shows the browser's menu. The test focuses a stateful button inside a cell before the menu loads and checks the node, focus, state and mount count after; it fails on the previous version. The changeset moves to [perf] and says that a test opening a menu right after render has to wait for the menu.
…menu load A shared scenario renders a cell with actions while its menu is still loading, edits an input and clicks a stateful button, focuses one of them, and lets the menu load. It then checks the same nodes, the input's value, the count, focus and a single mount, and that the menu opens from the keyboard (Shift+F10), moves with ArrowDown and returns focus on Escape. The body-cell suite focuses the editor; a new header-cell suite, in its own file so the menu starts unloaded, focuses the button. Both fail on the version where the content sat inside the Suspense boundary.
# Conflicts: # packages/core/src/Table/plugins/sortable/useTableSortable.test.tsx # packages/core/src/Table/plugins/sortable/useTableSortable.tsx
… file header The two Effects in ContextMenu's external-trigger mode now say which system each one syncs, as the pre-review check asks, and the TableCellContextMenu header fits the header length rule.
|
The latest push (4b73ec1) should address the requested changes.
The CI, Lint and CLI Smoke Test runs for this fork show "action required"; a maintainer needs to click "Approve and run workflows" for them to run. |
There was a problem hiding this comment.
Moving the menu out of the cell modules' static imports cuts the TableCell import from about 89 KB to about 9 KB gzip, and cell content now survives the menu load, but approval waits on an engineering-owner decision and three changes:
- Spec decision: until the lazily loaded menu arrives, right-click and Shift+F10 on a cell with
contextMenuActionsreach the browser's own menu and a long-press opens nothing, and no current TableCell or TableHeaderCell clause covers that window, so an engineering owner needs to record whether it is accepted (for example under TableCell PR1 and TableHeaderCell FR3, approved by commenting/approve-spec <full head SHA>, which the author may do if they are an engineering owner) or whether a cell must hold the invocation until its menu loads. - Desktop behavior change needs an owner decision: during that window a mouse right-click on a cell with actions opens the browser's menu instead of the cell's (
TableCellContextMenu.tsx:105), so either gate the fall-through to touch input by holding a mouse right-click until the menu loads, or cite the owner decision that accepts it. TableCellContextMenu.tsxkeeps a hand-synced copy of ContextMenu's trigger wrapper and cursor anchor that already renders the anchor differently (noleft/topinset), so please move that trigger into one small module that ContextMenu owns and render it from both places.wrapInTableContextMenuand itsLazyTableContextMenuintableContextMenu.tsxno longer have a caller and duplicate the getter rule inTableContextMenuForTrigger, so please delete them and update the file header.
The branch also conflicts with main in the imports of useTableRowExpansion.test.tsx, so please merge main. The engineering owner who requested changes on the earlier version still needs to re-review, though the fix they asked for is in place. CI has not run on this head yet: a maintainer adds the ci:run label so it runs.
[Automated review]
There was a problem hiding this comment.
No blocking issues in the code at this head. Cells without contextMenuActions no longer load the context menu, cell content survives the load, a loaded menu matches main, and a failed load keeps the table and retries; the TableCell.spec.md row has an engineering owner's spec approval for this head.
What remains is outside the code:
- humbertovirtudes's changes-requested review of an earlier head (the failed menu load) is still in force; this head keeps the table, drops the held invocation, retries the load and adds rejecting-import tests, so it needs their re-review or dismissal.
- CI has not run on this head yet; a maintainer adds the
ci:runlabel so it runs.
[Automated review]
|
/approve-spec e6ff52f |
humbertovirtudes
left a comment
There was a problem hiding this comment.
Recheck at e6ff52f: REVISE. The CI, Lint and smoke workflows on this head are waiting for maintainer approval, so nothing has run yet.
Resolved
- The earlier second-trigger blocker. The headless
createContextMenupath isn't onmain(ContextMenu FR10 records the gap), and the spec owner approved the spec at this head. Please mention the internalContextMenuForTriggerpath and the cell-owned held invocation in the FR10 implementation-gap note, so #8693 knows to absorb them. - A failed chunk load now renders
MenuUnavailable, drops the hold and retries, with four tests.
Blocking
- The delayed-replay interaction still has only jsdom evidence (AST-013 FR10; FR9/FR13 for hydration). Please add a Chromium interaction spec with a gated chunk covering an early right-click, Shift+F10 and a touch long press: native menu suppressed, a single replay, focus on the first row with no keyboard ring after a mouse open, focus returning on Escape, and server render → hydration → invocation.
Minor
- No test covers the held-invocation unmount cleanup (
TableCellContextMenu.tsx:219). Unmount a holding cell, let the load finish, and assert nothing opens and another cell's hold survives. The test should fail if that line is removed. - The replayed event has a null
currentTarget, so the focus-restore fallback is lost, and its pre-loadclientX/Ymisplace the anchor if the page scrolls during the load (TableCellContextMenu.tsx:199-200→ContextMenu.tsx:713). PasstriggerRef.currentas the focus element and store a trigger-local point when holding. ContextMenuItem's eager import grows by about 83 KB gzip. It's disclosed but not decided; record the decision or split the folder index.
Nits
- Drop the unrelated brace reformat in
apps/sandbox/perf/scenes.perf.spec.ts:70-72. - Remove the
resolveContextActionsre-export fromtableContextMenu.tsx; nothing imports it now, and importing it would load the menu.
|
I'll run a full review to re-check this with your note. |
There was a problem hiding this comment.
Changes requested: tables without context actions now skip the menu code, and an early right-click, Shift+F10 or long press opens the same menu once it loads; what remains is a real-browser test of the server-rendered path.
- Miss: the cell keeps its menu out of the hydrating render and holds an early invocation until the menu renders (
TableCellContextMenu.tsx:208-211,:320-328), but only a jsdomrenderToString/hydrateRoottest covers it, whilespec:AST-013's FR9/FR13 verification asks for a real-browser server render, hydration and post-hydration fixture, so please add a Chromium*.interaction.browser.spec.tsthat holds the menu chunk back, server-renders and hydrates a table, right-clicks a cell, and also pins the early right-click, Shift+F10 and long press.
Engineering owner humbertovirtudes asked for the same spec in their review of this head, and their changes-requested review stays in force until they re-review or dismiss it. Smaller and non-blocking: a scroll during the load opens the replayed menu off the cell, because the held clientX/Y predate the scroll (TableCellContextMenu.tsx:200); storing a trigger-local point when holding fixes it. CI has not run on this head yet; a maintainer adds the ci:run label so it runs.
[Automated review]
…he cell as focus target - A right-click or long press held before the menu loads now stores its point in the trigger's own box, so a scroll during the load keeps the menu on the content. The menu opens it through openAtTriggerPoint, with the trigger as its focus fallback; the held event had no current target. ContextMenu and the cell share contextMenuPoint for the keyboard and touch cases. - Tests: the held point across a scroll, the focus fallback, a cell that unmounts drops its own hold, and another cell's hold survives. - tableContextMenu no longer re-exports resolveContextActions; nothing imports it there, and importing it would load the menu.
…ell menu loads The spec server-renders a table with React, hydrates it in Chromium, and holds the lazy menu chunk until the test releases it. For a right-click, Shift+F10 and a touch long press that arrive first, it checks that the browser's menu stays shut, the menu opens once when the chunk arrives, focus lands on the first row (no ring after a mouse open), the menu opens at the pointer or finger, Escape hands focus back, and hydration reports no recoverable error. It fails when the held invocation is not replayed.
An earlier lint sweep on this branch reformatted one loop's braces in this file, which this pull request does not otherwise touch. This commit puts the file back exactly as main has it. It skips the commit hooks, because their eslint --fix (curly) would add the braces again.
The ContextMenu index re-exported its seven DropdownMenu aliases (ContextMenuItem, Divider, Group, CheckboxItem, RadioGroup, RadioItem, SubMenu) next to ContextMenu. With the table menu loaded on demand, an esbuild app that imported one alias from the package entry also loaded ContextMenu up front. Each alias now lives in a one-line module that the index re-exports, so its import reaches only the item it names. Public names and types are unchanged: the generated API report is identical to main's.
|
/approve-spec ca79cf1 |
There was a problem hiding this comment.
Changes requested: tables without contextMenuActions now skip the menu code, and an early right-click, Shift+F10 or long press opens the same menu once it loads, but two fixes remain.
TableCellMenuLoad.a11y.chromium.spec.tsresolves@astryxdesign/coretopackages/core/dist/index.js(line 109) and servesdist/astryx.css(line 160), but the CI jobs that run browser accessibility specs only install dependencies and download Storybook, so without a Core build the spec fails withCould not resolve ".../packages/core/dist/index.js"here and on every later pull request that touchesTable/,ContextMenu/or the long-press hook; please build the fixture from source, asTableVirtualization.release.a11y.chromium.spec.tsonmaindoes throughTableVirtualization.release.vite.mjs, with an SSR build for the server render.- The held long press at
TableCellContextMenu.tsx:231-239repeats the viewport-to-trigger conversion ofopenFromLongPressinContextMenu.tsx(lines 731-744), so please add that case besidecontextMenuPointinContextMenuTrigger.tsxand call it from both places.
Also worth a look: TableCellContextMenu.loadFailure.test.tsx:84 waits a fixed 20 ms for the mocked import and failed once under a loaded full run. The rest checks out: cell content survives the load, the three early invocations replay once in Chromium when Core is built, a failed load keeps the table, and the public API is unchanged. Engineering owner humbertovirtudes's changes-requested review of an earlier head stays in force until they re-review or dismiss it. CI has not run on this head yet; a maintainer adds the ci:run label so it runs.
[Automated review]
…rce, and share the long-press point - TableCellMenuLoad.a11y.chromium.spec.ts no longer needs a Core build. A Vite fixture (client and server builds, compiled with astryxStylex as Storybook does) renders the table on the server and hydrates it, and the spec holds the lazy menu chunk it finds in the client manifest. - longPressPoint sits beside contextMenuPoint in ContextMenuTrigger. The cell's held long press and ContextMenu's openFromLongPress both use it, so openFromLongPress now opens through openAtTriggerPoint. - The load-failure tests wait until the mocked import has run, instead of one fixed 20 ms wait that a loaded machine could outrun.
|
/approve-spec 23f819a |
There was a problem hiding this comment.
Approval waits on one owner action; no code changes are needed at this head.
- Engineering owner humbertovirtudes's changes-requested review of an earlier head is still in force. This head does what it and their later comment asked (the failed menu load keeps the table and retries, the Chromium early-invocation spec, the unmount-cleanup test, the trigger-local point and the per-alias ContextMenu modules), so it is theirs to re-review or dismiss.
The spec change to component:TableCell's PR1 verification row has an engineering owner's approval for this head, and no public API changes. Optionally, component:ContextMenu FR10's gap note could name the internal ContextMenuForTrigger path, as humbertovirtudes asked. CI has not run on this head yet; a maintainer adds the ci:run label so it runs.
[Automated review]
The FR10 implementation gap now says that table cells open the same menu through the internal ContextMenuForTrigger mode around a trigger they render, and that the cell holds an invocation that arrives before the menu loads. Both belong to the same gap as ContextMenu's own invocation handling. No code change.
|
/approve-spec 41d9640 |
There was a problem hiding this comment.
Approval waits on one owner action; no code changes are needed at this head.
- Engineering owner humbertovirtudes's changes-requested review of an earlier head still stands for this review, because it was dismissed by another maintainer rather than re-reviewed by humbertovirtudes, so a re-review of this head from humbertovirtudes, whose requests are all in place here, is what clears it.
The spec changes to component:TableCell's PR1 verification row and component:ContextMenu's FR10 gap note have an engineering owner's approval for this head, and no public API changes. Optionally, the PR1 row could also list the Chromium early-invocation spec beside the jsdom tests. CI has not run on this head yet; its workflows wait for a maintainer's approval.
[Automated review]
Dismissed by Cindy's agent under her standing rule for addressed reviews. Each point is fixed at 41d9640: a failed menu chunk load now renders nothing for that cell, drops the held invocation and retries, with rejecting-import tests (your recheck on Nov 10 marks this resolved); the changeset size and the TableCell verification rows were updated; and the follow-ups from your later recheck are in (the Chromium early-invocation interaction spec, the held-invocation unmount-cleanup test, the trigger-local point and focus element, per-alias ContextMenu modules, and the ContextMenu FR10 gap note). The automated review at this head reports no open findings. Thank you for the thorough reviews, @humbertovirtudes.
|
(Posted by Cindy's agent.) Thank you, @rhagigi, for this work. It now continues in #11569, which ports this PR onto current |
|
Closing as Superseded by #11569 |
Primary intent
Load the table-cell context menu only for cells with
contextMenuActions. Static imports currently pull the menu and its dependencies into every Table, TableCell and TableHeaderCell, including tables that never show a menu. Separating that code reduces the cells' eager JavaScript. This is a performance change, which none of the narrower templates covers.User or maintainer impact
Cells without actions render as before and do not import the menu. With actions, the cell renders its content and trigger immediately; the menu loads beside them after hydration, without replacing the content or losing its state and focus.
A right-click, Shift+F10 or long press before the load is held until the menu attaches. Only the latest cell's invocation is held, and a later press or key cancels it. Long presses keep the loaded menu's deadline, movement tolerance and lift behavior. A failed import leaves the table mounted, ends any pending early press, drops its invocation and restores native context-menu handling. A new mount or a later invocation can ask the loader again; this does not guarantee that a native browser import will refetch a failed module or recover a removed chunk.
There is no public API change. Action getters still resolve when the menu opens, and ordinary ContextMenu behavior is unchanged.
Problem and solution fit
resolveContextActionsandhasContextActionsinto a dependency-free module so cells, Table and its plugins can read actions without importing the menu. Existing resolver exports remain available.ContextMenuTriggeraround caller content and lazy-load only its menu sibling.ContextMenuForTriggeruses the same menu implementation with the cell's trigger and anchor; it is not exported from the package.createModuleLoaderinstead of duplicating its one-pending-load, success-cache and rejection-reset logic. The lazy failure fallback and cell cleanup remain unchanged.scripts/core-single-bundle.test.mjsto read the app's own entry. It took the first entry esbuild listed, which can be one of Core's lazy modules; the new lazy menu changed that order.openAtTriggerPointwith the trigger as the focus fallback. A scroll during the load then keeps the menu on the content. ContextMenu and the cell share thecontextMenuPointandlongPressPointhelpers inContextMenuTrigger.ContextMenuItem,ContextMenuDivider,ContextMenuGroup,ContextMenuCheckboxItem,ContextMenuRadioGroup,ContextMenuRadioItem,ContextMenuSubMenu) a one-line module that the ContextMenu index re-exports. With the menu split, an alias imported alone from the package entry otherwise reached ContextMenu. Names and types are unchanged; the generated API report matchesmain's.Authority
component:TableCellPR1: menu code loads only when actions are given. Its verification row names the tests and states how the contract holds across the menu load: an early invocation is held and replayed once, and a failed load keeps the table and returns the native menu. An engineering owner approved this row as a consistency change.component:TableCellFR4 andcomponent:TableHeaderCellFR3: preserve the full-cell trigger, density padding and action-getter behavior.component:ContextMenuFR1/FR10: preserve its invocation wiring and one open-state owner. FR10 still records the headless-menu implementation gap. Its gap note now also names the table cell's internalContextMenuForTriggerpath and the cell's held invocation.architecture:component-style-authoringINV6/INV7: report import sizes and keep the trigger wrapper and cursor anchor, with no additional caller-content DOM.spec:AST-013FR9 andarchitecture:interaction-modalityINV1: match server/hydrating markup and let programmatic menu focus follow the input that opened it.Change and evidence
Component size
The following measurements compare
mainat3582c71f(this branch's merge base) with this branch at23f819a1, usingpnpm -F @astryxdesign/core buildandnode .github/scripts/analyze-pr.js --main-record. The analyzer estimates a component's eager import-closure JavaScript and its CSS in the package stylesheet, not the JavaScript a particular page downloads. Bytes, gzip:The cell's own share includes about 4.7 KB that
mainadded recently: its input-modality module now also loads the keyboard-height tracker, and the cell starts modality tracking up front.MarkdownrendersTable, so its import estimate no longer includes the table menu.The analyzer measures only
ContextMenuItemamong the aliases. The same esbuild setup, importing each alias alone from the package entry, gives these eager gzip sizes (base → head):ContextMenuItem36,245 → 33,784,ContextMenuDivider7,074 → 7,175,ContextMenuGroup10,891 → 10,891,ContextMenuCheckboxItem37,823 → 38,128,ContextMenuRadioGroup11,414 → 11,623,ContextMenuRadioItem37,888 → 38,213,ContextMenuSubMenu88,839 → 86,796. Without the per-alias modules each reached about 125 KB. These are esbuild measurements of one import; they do not cover other bundlers, real pages or paint.Behavior checks
Body- and header-cell tests check the same content nodes, edited input, button state, one mount and retained focus after the menu loads, plus keyboard opening, ArrowDown and Escape focus return. Other cases cover no-action imports, an already-loaded menu, early touch and tap, competing cells, and cancellation by a later press or key.
The server-render test runs three fresh module graphs through
renderToStringandhydrateRoot, with no recoverable hydration errors. The early-mouse test checks that the first menu row receives a focus call withfocusVisible: false. Rejection tests preserve the cell node and page content, allow a later native context-menu event, and retry through a new root or an invocation on the existing cell. A touch begun before rejection cannot open the retried menu on its own.Further jsdom tests cover a held right-click that keeps its point in the cell across a scroll during the load, the trigger passed as the focus fallback, and a cell that unmounts before the load: it drops its own hold, and another cell's hold survives. The unmount test fails without the cleanup.
TableCellMenuLoad.a11y.chromium.spec.tsruns in Chromium. It builds a small fixture from source with Vite andastryxStylex, as Storybook does, so it needs no Core build. The server build renders a table with React, the browser hydrates it, and the spec's local server holds the menu chunk until the test releases it. For a right-click, Shift+F10 and a touch long press that arrive first, it checks that the browser's own menu stays shut (eachcontextmenuarrives with its default prevented), that the menu opens once when the chunk arrives, at the pointer or finger, with focus on its first row, and that Escape hands focus back. After the right-click the first row has no keyboard focus ring. Hydration reports no recoverable error, and the page logs no error. With the replay removed, all three cases fail.Fail-before controls catch content remounting, lost early invocations, hydration aborts, wrong focus options, import rejection escaping render, and a pending long-press timer surviving failure. The jsdom tests use a mocked loader; the Chromium spec uses a source build and a held chunk, but it does not prove recovery after a failed native chunk load, WebKit behavior or focus-ring pixels. The focus-fallback test checks that the trigger's
focusis called; the trigger is not a focusable element by itself.Writing rubric results
TableCell.spec.mdadds the five test files toverified_by, and its PR1 verification row cites them in place of the gap it recorded, including how the contract holds across the menu load.ContextMenu.spec.mdadds two sentences to FR10's implementation gap and its current-state note: table cells open the same menu through the internalContextMenuForTriggermode, and the cell holds an early invocation.R1 narration: none; the TableCell row states what the tests check, and the FR10 sentences state how cells open the menu now, in the present tense.
R2 research: none added to the record.
R3 evidence: the TableCell row names test files, not a pull request or commit; the FR10 sentences cite no evidence.
R4 rejected alternatives: none added.
R5 change references: none added.
R6 open questions: none added.
Scope
Testing
On Node 24.22.1, Vitest 4.1.11 and Playwright 1.61.1 (Chromium headless shell 149), at
23f819a1:pnpm exec vitest runonpackages/core/src/Table,ContextMenu,DropdownMenu,Layer,ListandItem, the useLongPress, longPressDetector, interactionModality and server-safe-components tests, andscripts/core-single-bundle.test.mjsandscripts/shared-identity.test.mjs: 108 files, 2,261 tests passed. The touch, modality, SSR and load-failure files passed five consecutive runs, 15 tests each.pnpm exec playwright test --config playwright.config.ts --project=chromium TableCellMenuLoad, with nopackages/core/distpresent: 3 tests passed in three consecutive runs.pnpm -F @astryxdesign/core typecheck, strict eslint on changed files,pnpm check:knowledgeandpnpm check:repo: passed. Repository pre-commit hooks passed, except on the one commit that restoresapps/sandbox/perf/scenes.perf.spec.tstomain's exact bytes: the hooks'eslint --fixwould reformat that file again, so that commit skips them.pnpm review:pre: the branch merges intomaincleanly. It reports one finding: 2,568 authored lines, over the 2,000-line limit. The lines over the limit are the Chromium spec and the tests a reviewer asked for.23f819a1. The later commit changes onlyContextMenu.spec.md;pnpm check:knowledgeandpnpm review:prepassed on it, apart from the size finding. The API report generated formainand for this branch atca79cf1bis identical; the later commit adds no public export (its new helper is internal toContextMenuTrigger)..changeset/table-cell-lazy-context-menu.md([perf], patch).