Skip to content

fix(DropdownMenu): a menu's sheet renders nothing at rest and drops two wrappers - #8392

Merged
cixzhang merged 4 commits into
mainfrom
fix/menu-sheet-inv7-rest
Oct 25, 2026
Merged

cixzhang merged 4 commits into
mainfrom
fix/menu-sheet-inv7-rest

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

User impact

On a phone, a DropdownMenu, MoreMenu or ContextMenu presented as a bottom sheet (presentation="adaptive" on a compact touch screen, or presentation="bottom-sheet") kept its closed sheet, with every item, mounted while the menu was closed. A page with a few adaptive menus carried a whole sheet per menu at rest. On touch, the menu rendered 7 to 9 more elements than the same menu on a desktop, which architecture:component-style-authoring INV7 does not allow (no more elements under a coarse pointer than under a fine one).

Problem and solution fit

  • Why the extra elements: MenuBottomSheet always rendered its BottomSheet, closed or open, and wrapped the menu's content in a Section whose only job was padding. The sheet header also kept a row wrapper when there was no back button to sit beside.
  • Why it matters: these elements are mounted, styled and laid out on every page that shows the menu, though nothing is visible until it opens.
  • The fix removes them without changing what an open sheet looks like or does:
    • MenuBottomSheet renders nothing while closed. It mounts as it opens and, after it closes, stays until its dialog has closed, so the exit plays out and focus returns to the trigger.
    • The sheet gets no content padding. The menu's own content element carries the same 16px top and 4px side inset, plus the container variables that bleeding rows read, so the Section wrapper goes.
    • The root heading stands alone; the header row wraps it only beside a sub-menu's back button.

Expected behavior and authority

architecture:component-style-authoring INV7 (current): components are built from minimal DOM, and a layer under a coarse pointer has at most as many elements as under a fine pointer.

Smallest restoration

  • No public API, prop or theme-target change.
  • One shared style module (menuBottomSheet.stylex.ts) carries the inset that the Section used to.
  • BottomSheet itself is not changed.
  • With the sheet open, the menu still renders more than the anchored popover (MoreMenu adaptive: 142 against 138). That remainder is BottomSheet's own anatomy (dialog, positioner, panel, handle, scroll and group wrappers), which every sheet consumer shares. It is out of scope here and tracked separately.

Evidence

Element count, document.body.querySelectorAll('*').length, in headless Chromium against Storybook builds of main and this change. Desktop is 1280px with a fine pointer; touch is 390px with a coarse pointer. Stories that render their sheet already open show the open state as "rest".

Story Pointer Rest Open After close
MoreMenu / adaptive touch 148 → 116 145 → 142 148 → 116
MoreMenu / adaptive desktop 141 → 141 138 → 138 141 → 141
ContextMenu / adaptive touch 140 → 108 (not driven) 140 → 108
ContextMenu / bottom sheet touch 146 → 143 146 → 143 146 → 108
DropdownMenu / action sheet, custom trigger touch 153 → 111 153 → 150 153 → 111
DropdownMenu / action sheet (rendered open) touch 155 → 152
DropdownMenu / adaptive action desktop 148 → 148 148 → 148 148 → 148
DropdownMenu / sub-menu adaptive fixture touch 169 → 169 143 → 143 143 → 143
  • Reproduction before the change: on touch, a closed adaptive MoreMenu has 148 elements against 141 on desktop.
  • Result after the change: a closed menu holds no sheet (touch 116, below desktop). An open sheet has 3 fewer elements. Focus returns to the trigger after a close, as before.
  • Representative unchanged path: desktop (popover) counts are identical. Screenshots of the open sheet before and after on touch differ in 21 to 30 pixels, from the heading's sub-pixel position now that it is no longer in a flex row.
  • Regression tests: the DropdownMenu sheet renders no dialog at rest, keeps it through its exit until the dialog's close event, then removes it. The content element carries the inset itself, with no Section above it and the root heading directly inside it. Both fail on main.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm vitest run packages/core/src/DropdownMenu packages/core/src/ContextMenu packages/core/src/MoreMenu packages/core/src/BottomSheet: 680+ pass.
  • Selector and Popover suites pass.
  • Core tsc, ESLint (strict) and Prettier are clean.
  • Headless Chromium against Storybook builds as above: counts, open and close, focus after close, and before/after screenshots at 390px.

…wo wrappers

An adaptive or bottom-sheet DropdownMenu, MoreMenu or ContextMenu kept its
whole closed BottomSheet mounted at rest, every item included, so a phone
rendered 7 to 9 more elements than a desktop with the menu closed
(architecture:component-style-authoring INV7). Now:

- MenuBottomSheet renders nothing while closed. It mounts as it opens and,
  after it closes, stays only until its dialog has closed, so the exit
  plays out and focus returns to the trigger.
- The Section wrapper between the sheet and the menu's content is gone:
  the sheet has no content padding and the menu's own content element
  carries the same 16px / 4px inset and container variables.
- The root view's heading stands alone; the header row wraps it only
  beside a sub-menu's back button.

Opening the sheet still renders more than the anchored popover because of
BottomSheet's own anatomy; that remainder is tracked separately.
@vercel

vercel Bot commented Oct 25, 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 Oct 25, 2026 5:53pm UTC

Request Review

@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Oct 25, 2026
@astracat-bot

astracat-bot Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 25, 2026, 6:25 PM UTC

@github-actions

github-actions Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

Modified Components

ContextMenu (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Entry File (ESM) 1.1KB 1.1KB 0B
Lines of Code 639 668 -
Complexity Very High Very High (84) -

Component Size

Component Import before Import after Delta CSS before CSS after Delta
core/ContextMenu 73.9KB 73.6KB -341B 14.2KB 14.2KB -21B
core/ContextMenuItem 16.4KB 16.4KB 0B 5.0KB 5.0KB 0B
core/DropdownMenu 69.0KB 68.7KB -309B 14.4KB 14.3KB -92B
core/DropdownMenuCheckboxItem 16.0KB 16.0KB 0B 5.4KB 5.4KB 0B
core/DropdownMenuDivider 6.5KB 6.5KB 0B 3.4KB 3.4KB 0B
core/DropdownMenuGroup 5.9KB 5.9KB 0B 3.1KB 3.1KB 0B
core/DropdownMenuItem 15.3KB 15.3KB 0B 4.9KB 4.9KB 0B
core/DropdownMenuRadioGroup 5.9KB 5.9KB 0B 3.1KB 3.1KB 0B
core/DropdownMenuRadioItem 16.0KB 16.0KB 0B 5.4KB 5.4KB 0B
core/DropdownMenuSubMenu 54.5KB 54.5KB 0B 9.3KB 9.3KB 0B
core/Markdown 133.1KB 132.8KB -352B 16.9KB 16.9KB -11B
core/MoreMenu 69.2KB 68.9KB -323B 14.4KB 14.3KB -92B
core/Table 80.0KB 79.7KB -307B 14.6KB 14.6KB +8B
core/TableCell 74.9KB 74.6KB -328B 14.4KB 14.3KB -24B
core/TableHeaderCell 74.7KB 74.4KB -324B 14.3KB 14.3KB -25B

Sizes are gzip. Import counts the JavaScript the import loads eagerly; CSS counts the package stylesheet rules referenced by the modules it can load from its own package, lazily loaded ones included.

Bundle Size Summary

Gzip figures measure each package's entry file, not the code an import pulls in.

Package Entry (ESM) Entry gzip before Entry gzip after Delta
@astryxdesign/core 4.9KB 1.2KB 1.2KB 0B
Package stylesheet Gzip before Gzip after Delta
@astryxdesign/core 33.7KB 33.8KB +62B

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

48 of 502 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 753,933
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,072
RichTextEditor Markdown parity: side by side probe dark 556,900
RichTextEditor Markdown parity: side by side probe light 538,816
Chat Full AI Chat probe light 230,823
Chat Full AI Chat probe dark 229,805
AppShell With Mobile Nav probe light 217,010
AppShell With Mobile Nav probe dark 216,960
Collapsible Dividers probe dark 66,445
Collapsible Dividers probe light 66,445
AppShell Playground neutral dark 65,198
AppShell Playground neutral light 63,788
Chat Default neutral dark 36,304
Chat Default neutral light 35,767
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,406
Chat With Attachments probe dark 11,232

and 28 more.


Generated by PR Enrichment workflow | Storybook | Sandbox | 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.

Requesting changes: unmounting the closed menu sheet works as described (fewer elements at rest, the exit still plays, focus returns to the trigger), but compound-mode ContextMenu sheets (menuContent with presentation="bottom-sheet", or "adaptive" on touch) lose their inset, so the first row slides under the grab handle. Please give the compound sheet branch in ContextMenu.tsx the same menuBottomSheetStyles.content and styles.sheetMenuInset, and replace the source-text padding test with a rendered assertion on a data and a compound sheet. Two smaller follow-ups are noted inline: naming the native dialog in the set-state-in-effect disable reason, and adding a regression for the new --container-padding-* publication.

[Automated review]

stylex.props(styles.sheetMenu, xstyle),
stylex.props(
styles.sheetMenu,
menuBottomSheetStyles.content,

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.

Only this data-mode element gets the sheet inset. In compound mode (menuContent) the sheet renders renderedMenu, whose sheet branch (line 716) applies only styles.sheetMenu. With padding={0} on the sheet and no Section, the inset above the first row drops from 20px to 4px (the row slides under the grab handle) and the side inset from 8px to 4px. Applying menuBottomSheetStyles.content and styles.sheetMenuInset in that branch too would restore the previous layout.

Comment on lines +304 to +305
expect(source).toContain("paddingBlockStart: spacingVars['--spacing-4']");
expect(source).toContain('paddingBlockEnd: 0');

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.

This checks the style module's source text, so it still passes while the compound sheet has no inset. Opening a data sheet and a compound sheet and asserting the menu element's padding would catch that.

}
const dialog = panelRef.current?.closest('dialog');
if (dialog == null || !dialog.open) {
// eslint-disable-next-line @eslint-react/set-state-in-effect -- the closed sheet's exit is already over: unmount it

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.

Could the reason name the external system it reacts to, for example that the native dialog is already closed so its exit is over? The Effect reads dialog.open and listens for close.

Comment on lines +181 to +185
sheetMenuInset: {
paddingBlockStart: `calc(${spacingVars['--spacing-4']} + ${spacingVars['--spacing-1']})`,
paddingBlockEnd: spacingVars['--spacing-1'],
paddingInline: `calc(${spacingVars['--spacing-1']} + ${spacingVars['--spacing-1']})`,
},

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.

This applies 20px / 8px / 4px while menuBottomSheetStyles.content publishes 16px / 4px / 0px in --container-padding-*. Nothing in the data path reads those variables today, but a bleed child would compensate against them. Either publish the applied inset here or note why the Section's values are kept.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 25, 2026
The compound (`menuContent`) branch of ContextMenu's sheet never received
the inset that replaced the Section wrapper, so the first row lost 16px
and slid under the sheet's grab handle. It now takes the same
menuBottomSheetStyles.content and sheetMenuInset as the `items` branch.

Tests: the source-text padding check becomes a rendered assertion on both
an `items` and a compound sheet: no Section above the menu element, the
inset on the element itself, and the container padding it publishes to
bleeding rows. The compound case fails on the previous head. The
set-state-in-effect reason names the native dialog.

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

Requesting changes: unmounting the closed sheet works as described (fewer elements at rest, the exit still plays, focus returns to the trigger, and the compound ContextMenu inset is back), but the first open of a DropdownMenu or MoreMenu sheet now shows only its heading for about 300 ms before the rows appear, because the lazily loaded action list first renders when the sheet mounts. Please make the rows resolve at rest again, for example by loading the action list with the sheet host, and add a cold first-open test that does not call warmMenuBottomSheet. Please also make ContextMenu's published --container-padding-* match the 20px / 8px inset sheetMenuInset applies, or stop publishing on that element.

[Automated review]

return () => dialog.removeEventListener('close', handleClose);
}, [isMounted, isOpen]);

if (!isMounted) {

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.

Returning null here keeps DropdownMenu's lazy MenuBottomSheetActionList from rendering until the sheet opens, so it first resolves in the opening commit. In Chromium the first open shows a 101px sheet with only the heading and the rows arrive about 300 ms later (also in CI's production Storybook, with no request after the tap); the base rendered the rows at rest. Could the action list resolve at rest again, for example by loading it in the same lazy module as the sheet host?

Comment on lines +181 to +185
sheetMenuInset: {
paddingBlockStart: `calc(${spacingVars['--spacing-4']} + ${spacingVars['--spacing-1']})`,
paddingBlockEnd: spacingVars['--spacing-1'],
paddingInline: `calc(${spacingVars['--spacing-1']} + ${spacingVars['--spacing-1']})`,
},

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.

This applies 20px / 8px / 4px, but menuBottomSheetStyles.content publishes 16px / 4px / 0 in --container-padding-* on the same element. The container-padding host rule asks published values to match the applied padding; overriding the four variables here with the applied inset (or not publishing on this element) would conform, with the test updated to match.

});

it('renders nothing of the sheet at rest and keeps it through its exit', async () => {
await warmMenuBottomSheet();

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.

Warming resolves both lazy modules, so no suite sees a cold first open, which is where the header-only sheet appears. A test with the modules released at rest (like DropdownMenuLazySheet.test.tsx) that asserts the rows exist in the opening commit would cover it.

…ntextMenu publishes the inset it applies

- A closed menu sheet renders nothing, so its lazily loaded action list
  first rendered on the first open: it suspended there, and React held the
  rows back for about 300ms, leaving a heading-only sheet. A sheet menu
  now preloads the action list at rest, and a list mounted after the load
  renders directly instead of through lazy(), so the rows commit with the
  opening. The choice is made once per mount, so a load that lands while
  a list is mounted never remounts it.
- ContextMenu's sheet published the 16px / 4px inset while applying
  20px / 8px; it now publishes the padding it applies.

Tests: a cold bottom-sheet DropdownMenu (no warm-up) loads the sheet and
rows at rest and renders the actions in the same commit as the opening;
it fails without the preload and without the direct render. The
ContextMenu sheet assertions expect the published 20px / 8px.

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

Recommending approval: a closed DropdownMenu, MoreMenu or ContextMenu bottom sheet no longer mounts (an adaptive MoreMenu on touch drops from 149 to 117 elements at rest), while the open sheet keeps its layout, shows its rows on the first open, plays its exit and returns focus to the trigger. The compound ContextMenu inset and the published container padding now match what is applied, and the new tests cover the at-rest absence, the exit, the inset and a cold first open. No further changes are needed here; the open sheet's remaining excess over the popover comes from BottomSheet's own anatomy, which the description already leaves to a follow-up.

[Automated review]

@cixzhang
cixzhang merged commit 7d48989 into main Oct 25, 2026
71 checks passed
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 26, 2026
…into the animator's React hook and browser proofs

The motion table files keep this branch's copy, main's meta#8053 table plus the
chain's additions. The harness takes main's fail-closed compareCurve and its
tests beside meta#8446's modules, index and README.
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 26, 2026
Main's menu sheet renders nothing at rest and drops two wrappers (meta#8392): a sub-menu level's heading now sits in a row with its back button and the root's stands alone. This branch keeps its level regions on that structure: the opened level is still read from the current items, and its own header and footer, keyed by level, replace the menu's. ContextMenu's suite keeps this branch's plain-row case beside main's sheet-inset cases, which replace the old padding check.
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 26, 2026
meta#7839's sheet regions meet main's new sheet structure (meta#8392) here as they do at meta#7839's own head: the level regions sit on the new structure.
@github-actions
github-actions Bot deleted the fix/menu-sheet-inv7-rest branch October 26, 2026 06:31
cixzhang pushed a commit that referenced this pull request Oct 30, 2026
…er an unhandled rejection (#8478)

## User impact

A bottom-sheet DropdownMenu preloads its action list at rest. When that load fails (a dropped or flaky connection), the page gets an unhandled promise rejection in the console. The rejected load also stays cached, so every later open of the menu fails to show its rows until a reload. In this repository's CI, the same unhandled rejection fails the UI test shard that runs `DropdownMenu.ssr.test.tsx` while every test passes, as on #8353, #8229 and #8211.

## Problem and solution fit

- Why does it occur? `preloadMenuBottomSheetActionList` starts the load with `void loadActionList()`: nothing handles a rejection, and `actionListLoad ??=` keeps the rejected promise.
- Why does it harm the task? An unhandled rejection is reported as an error, and a cached rejection turns one network blip into a menu whose rows never appear.
- Why does that matter? The preload only exists to make the first open instant; it must never break the open. In tests, the SSR file can finish while its preload is still importing; the environment tears down mid-import and the rejection fails the run.

The fix handles the preload's failure and drops the failed load, so the next preload or open asks the loader again. The SSR test waits for the sheet modules before it ends.

## Expected behavior and authority

The sheet loads on demand (#7709) and preloads at rest so the first open shows its actions at once (#8392). A preload is an optimization: its failure surfaces no error and blocks no retry.

## Smallest restoration

- `loadActionList` clears its cached load when the import rejects.
- `preloadMenuBottomSheetActionList` handles the rejection.
- `DropdownMenu.ssr.test.tsx` awaits the two sheet modules after unmounting.

No API, rendering or timing change.

## Evidence

- Reproduction before the change: on main e9b3f3e, `DropdownMenu.ssr.test.tsx` run alone fails 5 of 6 runs with three `EnvironmentTeardownError`s each, and the new unit test records the unhandled rejection.
- Result after the change: the SSR file passes 8 of 8 runs alone, and the unit test passes.
- Representative unchanged path: all 10 DropdownMenu test files (312 tests) pass.
- Regression test or other mutation-sensitive proof: `lazyMenuBottomSheet.test.ts` fails the list's import once, then checks there is no unhandled rejection and that the next call imports it again. Keeping the rejected load cached fails it ("expected 1 to be 2").

## Scope

- [x] One defect is restored.
- [x] Separable contradictory or unsettled tagalongs were removed or split.
- [x] No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
- [x] Public text and artifacts contain no internal Meta context.

## Testing

- At 3962530: the changeset and comments promise only what holds everywhere (no unhandled rejection, no kept failure); the unit and SSR tests: 2 passed; changeset coverage: passes.
- At 8877d94 (adds the Changeset): `node scripts/release/changeset-coverage.mjs pr --base e9b3f3e` fails at 4d8e178 and passes here (`[fix]`, `@astryxdesign/core`); `pnpm check:changesets`: valid.
- `pnpm exec vitest run --project ui packages/core/src/DropdownMenu/lazyMenuBottomSheet.test.ts`: fails on main, passes here.
- `pnpm exec vitest run --project ui packages/core/src/DropdownMenu/DropdownMenu.ssr.test.tsx`, alone, 8 times: 8 of 8 (main: 1 of 6).
- `pnpm exec vitest run packages/core/src/DropdownMenu`: 10 files, 312 tests.
- `tsc -p packages/core/tsconfig.json --noEmit`, eslint and prettier on the changed files: clean.
vjeux added a commit to vjeux/astryx that referenced this pull request Nov 3, 2026
…into the animator's React hook and browser proofs

The motion table files keep this branch's copy, main's meta#8053 table plus the
chain's additions. The harness takes main's fail-closed compareCurve and its
tests beside meta#8446's modules, index and README.

This branch was successfully deployed

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

Labels

CLA Signed This label is managed by the Meta Open Source bot. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant