Skip to content

perf(core): load the Selector bottom-sheet frame on demand (#12018) - #12075

Merged
cixzhang merged 27 commits into
meta:mainfrom
MuhammadAusafJamal:perf/defer-static-imports
Nov 25, 2026
Merged

cixzhang merged 27 commits into
meta:mainfrom
MuhammadAusafJamal:perf/defer-static-imports

Conversation

@MuhammadAusafJamal

@MuhammadAusafJamal MuhammadAusafJamal commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Primary intent

Defer the Selector and MultiSelector bottom-sheet presentation so it loads on the trigger's intent through the shared module loader. Addresses item 3 of #12018.

This is a performance improvement reducing eager JavaScript loaded before first paint on pointer/desktop presentations; other.md fits because this is neither a bug fix nor a new feature.

User or maintainer impact

Desktop and pointer consumers (where Selector and MultiSelector present as a popover) no longer eagerly bundle the mobile bottom-sheet frame, Section, and Heading dependencies into their first-paint chunk.

A page using Selector loads about 4 KB less eager JavaScript (gzip) on first paint (check-component-import-boundaries: 118.5 KB → 114.5 KB, −4.0 KB). Compact touch and explicit presentation="bottom-sheet" load the sheet frame when a finger or pointer lands on the trigger, the trigger takes focus, or the list is asked to open. A tap made before the frame arrives opens the sheet once it does, with focus in the list.

Problem and solution fit

  • Why was the bottom sheet bundled eagerly? Selector.tsx and MultiSelector.tsx imported SelectorBottomSheet statically, which previously statically bundled Heading and Section.
  • Why load on intent through the shared loader? architecture:component-import-boundaries INV1 reaches a surface module only through import() behind the shared module loader; INV2 starts the load on intent (pointer down, focus, open request) and never before it, during server render or during hydration; INV4 honours an intent made before the load once; INV5 lets the load move nothing. SelectorBottomSheet.tsx holds a createModuleLoader for SelectorBottomSheetFrame, and loadSelectorBottomSheet() starts it. The trigger calls it from a capturing pointer-down, from a mouse or pen entering it, and from focus (when the selector can open), and useSelectorPresentation's show() calls it for the sheet. A failed load warns once, is not kept (the shared loader drops a failed load), and drops a held open, so the trigger never reports a list that never shows (INV6). The host reads the loaded frame through useSyncExternalStore and renders nothing until it arrives, so it never suspends, and an open requested before then stays requested until the frame renders it.
  • Why direct submodule imports? SelectorBottomSheetFrame.tsx imports ../Heading/Heading, ../Section/Section, and ../BottomSheet/BottomSheet directly, and Section.tsx imports ../utils/mergeProps, eliminating barrel traversal within the lazily imported module graph.

Authority

  • architecture:component-import-boundaries: eager bundle boundaries and avoiding barrel imports within lazily imported module graphs.

Change and evidence

  • packages/core/src/Selector/SelectorBottomSheetFrame.tsx:
    • Contains the presentation frame (BottomSheet, Section, Heading).
    • Directly imports ../Heading/Heading, ../Section/Section, and ../BottomSheet/BottomSheet.
  • packages/core/src/Selector/SelectorBottomSheet.tsx:
    • The host: a createModuleLoader for ./SelectorBottomSheetFrame, loadSelectorBottomSheet(), and SelectorBottomSheet, which renders the loaded frame (server snapshot: none).
  • packages/core/src/Selector/useSelectorPresentation.ts: show() starts the load for the sheet, and the controller returns preloadSheet.
  • packages/core/src/Selector/Selector.tsx, packages/core/src/MultiSelector/MultiSelector.tsx: the trigger's focus and a capturing pointer-down on the control box call preloadSheet when the selector can open.
  • packages/core/src/Selector/Selector.sheetLoad.test.tsx (new): nothing loads before intent or on a read-only selector's focus; pointer down starts one load; focus and the open add none; a tap before the frame arrives opens one sheet, with focus in the listbox, once it does. It fails on the lazy-at-mount host (a load before intent).
  • packages/core/src/MultiSelector/MultiSelector.sheetLoad.test.tsx (new): a held open (focus, then ArrowDown, before the frame arrives) leaves the trigger collapsed with no aria-controls or aria-activedescendant until the sheet renders its listbox; a caller's renderTrigger control starts the load on a pointer down and on a mouse entering it, each checked on its own by counting loadSelectorBottomSheet calls (the ref the selector hands over registers preloadSheet and preloadSheetOnPointerEnter), and the trigger names the listbox only while the sheet is open.
  • Selector/hooks.ts, MultiSelector/hooks.ts: Selector and MultiSelector call internal useComboboxInternal and useMultiComboboxInternal, which take whether the open list is in the document. While an open is held, a second press, Enter or Space keeps it and closes or picks nothing; Escape and Tab still drop it. The public useCombobox and useMultiCombobox keep their signatures and wrap the internal hooks, so their callers (CommandPalette among them) are unchanged.
  • useSelectorPresentation.ts: a held open (an open made before the sheet's frame renders its list) ends when a press lands outside the trigger or focus moves to another element. No sheet then appears later over what the person turned to, and focus stays where they put it. A press elsewhere or a focus move is a later intent, which replaces a held one (architecture:component-import-boundaries INV4; architecture:interaction-modality INV8). The open starts a second watch from the shared outside-press helper (shadow roots included), which counts as no layer dismissal, so a modal host's backdrop press still closes the host, and a focus listener on the trigger; both stop when the list shows or on close, and the watch also stops on unmount.
  • Layer/outsidePress.ts: watchOutsidePress takes an isDismissal option. It defaults to true, which keeps today's behaviour, and no existing caller passes it, so Popover, DropdownMenu, ContextMenu, the date inputs and the sheets are unchanged; all existing outsidePress.test.ts and useBackdropPress.test.tsx cases pass unchanged. False makes a press outside count no outside dismissal; only the Selector's held open passes it.
  • Selector.sheetHeldBackdrop.test.tsx (new): a backdrop press on a Dialog that holds the Selector, during the hold, still closes the Dialog; outsidePress.test.ts covers isDismissal: false.
  • Selector.sheetHeldPressOutside.test.tsx, Selector.sheetHeldOtherSelector.test.tsx (new): a press elsewhere during the hold leaves no open sheet; moving to a second selector during the hold opens only that selector's sheet. Both fail without the change.
  • utils/moduleLoader.ts (shared by every deferred surface): createModuleLoader gains an onLoadFailure option, subscribe() and tryLoad(). These members are additive: load() and loaded() behave as before, and no existing caller changes (MobileNav, DropdownMenu's sheet, Toast, Text's truncation tooltip and keyboard cut text). The sheet host makes one tryLoad() call and subscribes with subscribe. moduleLoader.test.ts covers both load() as existing callers use it and the new members.
  • Selector.sheetHeldInputs.test.tsx and utils/moduleLoader.test.ts (new): a second press, Enter and Space during a held open pick nothing and the sheet opens once; a failed tryLoad reports and resolves false, the next asks again, and a load tells its subscribers.
  • useSelectorPresentation.ts: the controller owns the listbox attachment (attachListbox, isListboxMounted) and returns one rule for both components: isListShown (open and in the document) and isListboxNamed.
  • Selector.tsx, MultiSelector.tsx: in the sheet presentation the trigger reports aria-expanded="true" and names the listbox in aria-controls together, only while the sheet is open and its listbox is in the document (INV3). An open made before the frame arrives is held (INV4): the trigger stays collapsed and names nothing until the sheet shows. A load that another selector starts leaves a closed trigger's ARIA unchanged. The popover presentation is unchanged. While a MultiSelector open is held, its trigger names no active option either. The chevron's rotation and its theme state follow the same expanded state, so during a held open nothing shows the list as open.
  • Selector.sheetActiveDescendant.test.tsx: the held open before the surface loads now expects aria-expanded="false" and no aria-controls, where it expected "true" for a list that was not yet in the document.
  • packages/core/src/Selector/__tests__/SelectorSheetHeldOpen.a11y.chromium.spec.ts (new): in Chromium, with the sheet frame's chunk held, a tap leaves the trigger collapsed and naming nothing, axe finds no violation, and once the chunk is released the sheet opens with aria-expanded="true" and aria-controls naming its listbox, axe again clean.
  • packages/core/src/Selector/Selector.sheetLoadHover.test.tsx (new): a mouse entering the trigger starts the load, and a finger entering it does not (its pointer down does); once the frame has loaded, a closed trigger names no listbox, and only the open one does. It fails without the trigger's onPointerEnter.
  • packages/core/src/Selector/Selector.sheetLoadFailure.test.tsx (new, INV6): with a rejecting loader, an open closes again (aria-expanded="false", no sheet), warns once, and the next open asks for the frame again.
  • packages/core/src/Section/Section.tsx:
    • Swapped barrel ../utils import to ../utils/mergeProps.
  • packages/core/src/Selector/Selector.sheetActiveDescendant.test.tsx:
    • Updated mock and warm-up from ../BottomSheet/BottomSheet to ./SelectorBottomSheetFrame.
  • packages/core/src/Selector/Selector.ssr.test.tsx:
    • Added SSR hydration test ensuring bottom-sheet Selector hydrates without console or recoverable errors.
  • packages/core/src/Selector/Selector.test.tsx and packages/core/src/MultiSelector/MultiSelector.test.tsx:
    • Added warm-up import for SelectorBottomSheetFrame.
  • internal/eslint-plugin-astryx/no-internal-barrel-import.baseline.json:
    • Dropped now-stale baseline entries for SelectorBottomSheet.tsx and Section.tsx.
  • .changeset/selector-multiselector-defer-selectorbottomsheet-i4zp.md:
    • Patch changeset documenting the first-paint reduction (about 4 KB gzip) and the intent load.

Evidence:

  • scripts/check-component-import-boundaries.mjs: on the earlier base (ac873683), the Selector entry drops from 118.5 KB to 114.5 KB (−4.0 KB gzip). After merging main (d63c2497), CI's boundary check prints the base and head figures for the current base.
  • First-load JavaScript on the four reference pages (pnpm size:pages, base d63c2497, minified / gzip bytes). The shared module loader reaches every page through Text; each change is under the 0.3 KB gzip limit:
Page (components) Base Head Change
docs (Text, Heading, Link, Card, Divider, List) 241,374 / 79,924 241,533 / 80,003 +159 / +79
form (Button, IconButton, TextInput, CheckboxInput, Text, Heading, Card) 327,253 / 110,659 327,412 / 110,748 +159 / +89
menu (DropdownMenu, ContextMenu, Button, Text) 397,910 / 136,249 398,069 / 136,319 +159 / +70
table (Table, Text, Button) 379,132 / 129,044 379,730 / 129,171 +598 / +127
  • scripts/core-single-bundle.test.mjs (unchanged here): passes.
  • packages/core/src/Selector/Selector.sheetLoad.test.tsx and Selector.sheetLoadFailure.test.tsx: pass.
  • packages/core/src/Selector/Selector.sheetActiveDescendant.test.tsx: passed.
  • packages/core/src/Selector/Selector.ssr.test.tsx: passed.
  • packages/core/src/Selector/Selector.test.tsx & packages/core/src/MultiSelector/MultiSelector.test.tsx: all bottom-sheet tests passed.
  • scripts/check-knowledge.mjs: Templates and records aligned.

Scope

Components: Selector, MultiSelector

  • This PR has one primary intent.
  • Independently removable deltas were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

# Eager bundle import boundaries and gzip verification (about -4 KB)
node scripts/check-component-import-boundaries.mjs

# Core bundle test (verifies lazy module graph and code splitting)
node node_modules/vitest/vitest.mjs run scripts/core-single-bundle.test.mjs --project node

# Bottom sheet tests and SSR hydration for Selector and MultiSelector
node node_modules/vitest/vitest.mjs run packages/core/src/Selector/Selector.sheetActiveDescendant.test.tsx packages/core/src/Selector/Selector.ssr.test.tsx packages/core/src/Selector/Selector.test.tsx packages/core/src/MultiSelector/MultiSelector.test.tsx --project ui -t "bottom sheet"

# Knowledge alignment
node scripts/check-knowledge.mjs

Maintainer reshape

The intent load through the shared module loader is a maintainer edit by @cixzhang on top of @MuhammadAusafJamal's frame split, per architecture:component-import-boundaries INV1, INV2, INV4 and INV5. The size win and the frame module are the contributor's.

Real-browser evidence

Maintainer device runs at 2ef8d58a, against main at the merge base ac873683:

  • Pixel 8 (Android 17, Chrome 157) and iPhone 14 (iOS 26.2, Safari), Selector bottom-sheet story:
    • a tap before the sheet's code arrives opens exactly one sheet, with focus in the listbox;
    • while it waits, only the trigger's focus ring changes; the sheet enters fully drawn;
    • keyboard focus then Enter, a slow chunk (held 1.5 s) and warm opens match main;
    • with the chunk's first request failing, the trigger ends collapsed, and the next tap requests the chunk again and opens the sheet (3/3).
  • Desktop headless Chromium 149, MultiSelector with renderTrigger, mouse hover then click: when idle, the opener has no aria-controls and no sheet code is loaded; the hover loads it; the click opens one sheet with focus in the listbox (3/3).
  • Android emulator (Chrome 145), the same opener, touch tap: opens one sheet with focus in the listbox (3/3).

Since then, the trigger's aria-expanded and aria-controls change together, only once the sheet's listbox is in the document, and the renderTrigger opener registers the shared intent callbacks. The custom-trigger cell is re-checked at this head.

Follow-up: #13751 (navigation keys during a held open, and a comment length).

@vercel

vercel Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 25, 2026 6:58am UTC

Request Review

@astracat-bot

astracat-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

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

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 16, 2026
@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge needs:design-review Affects visuals — Design should review labels Nov 16, 2026

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

Changes requested. The deferral works: pages with one Selector or MultiSelector lose about 4.7 KB gzip of first-load JavaScript, and the reference pages are unchanged. Five fixes are needed first:

  • SelectorBottomSheet.tsx is now the root of a lazily loaded module graph but still imports the ../Heading and ../Section barrels (and Section.tsx imports ../utils), so scripts/core-single-bundle.test.mjs "imports no barrel from inside a lazily imported module graph" fails; import ../Heading/Heading, ../Section/Section and ../utils/mergeProps directly.
  • In the same file, "keeps the bottom sheet out of the startup chunks of a code-split app" now fails only because it walks from the first output that has an entryPoint, which the new lazy entry turns into the lazy PowerSearchBottomSheet chunk; start the walk from the app's own entry, where the List app's startup chunks hold no BottomSheet.
  • The new comments at Selector.tsx:1169 and MultiSelector.tsx:1110 cite a knowledge record, which makes no-comment-provenance.baseline.mjs --check fail (and the cited rule covers minimal DOM, not loading), so drop the citation and keep the reason.
  • The lazy host and its preload Effect are copied into both Selector.tsx and MultiSelector.tsx for one shared sheet, so make SelectorBottomSheet.tsx itself the lazy host (same export and props) and move the frame into a module that only it imports.
  • The changeset says the sheet "mounts only when opened", but the host renders the closed sheet at rest whenever the bottom-sheet presentation is active (Selector.tsx:2262-2274), so say instead that it loads and mounts the closed sheet after the first client render.

Non-blocking: because the host already renders the lazy element at rest, the preload Effect starts the same import a second time and can go.

Claims and files checked

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

  • Claim: desktop and pointer pages no longer carry the sheet frame in their first load. Verified: the frame, Section and Heading leave the first load, and the import-boundaries check passes.
  • Claim: a Selector page loads about 3.8 KB less gzip (108.4 KB to 104.6 KB). Verified by the import-boundaries check; the reference-page measure shows 4.7 KB less.
  • Claim: compact touch and explicit bottom-sheet selectors preload the sheet chunk and open as before. Verified: the chunk loads after the first client render, and the bottom-sheet and accessibility tests pass.
  • Claim: the sheet mounts only when opened. False: the host renders the closed sheet at rest (Selector.tsx:2262-2274, MultiSelector.tsx:2536-2548).
  • Claim: the change follows the Tokenizer and PowerSearch pattern under the cited style-authoring rule. The pattern is followed, but the citation is false: that rule covers minimal DOM, and the loading rule is the import-boundaries record.
  • Claim: SelectorBottomSheet exports its props and imports BottomSheet directly. Verified (SelectorBottomSheet.tsx:14, :29).
  • Claim: tests warm the sheet module and the bottom-sheet tests pass. Verified: five Selector and MultiSelector test files pass.
  • Claim: the core typecheck passes. Verified.
  • Claim: knowledge templates and records are aligned. Verified.
  • Claim: the pre-review script reports 0 findings. Not reproduced (it needs a git remote).
  • File .changeset/selector-multiselector-defer-selectorbottomsheet-i4zp.md: finding (false "mounts only when opened").
  • File packages/core/src/Selector/SelectorBottomSheet.tsx: finding (barrel imports inside the lazy graph).
  • File packages/core/src/Selector/Selector.tsx: findings (duplicated host, record citation, redundant Effect, false comment).
  • File packages/core/src/MultiSelector/MultiSelector.tsx: findings (the same as Selector).
  • File packages/core/src/Selector/Selector.test.tsx: clear.
  • File packages/core/src/MultiSelector/MultiSelector.test.tsx: clear.

Automated review (maintainer link)

Comment thread packages/core/src/Selector/Selector.tsx Resolved
Comment thread packages/core/src/Selector/Selector.tsx Resolved

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

Changes requested. The deferral works: a page with one Selector or MultiSelector loads about 4.8 KB less gzip JavaScript on first load, the reference pages are unchanged, and the points from the last review are fixed. Three fixes are needed:

  • Miss: Selector.sheetActiveDescendant.test.tsx now fails, because it holds ../BottomSheet/BottomSheet while the first open waits on ./SelectorBottomSheetFrame, so point its vi.mock and its vi.importActual warm-up at ./SelectorBottomSheetFrame (the test passes with that change).
  • The pull request description still describes the previous revision (a host and preload Effect in Selector.tsx and MultiSelector.tsx, a direct BottomSheet import in SelectorBottomSheet.tsx, and a minimal-DOM rule as authority), so rewrite it for this head: the frame in SelectorBottomSheetFrame.tsx, the host in SelectorBottomSheet.tsx, the Section.tsx import, the bundle-test entry fix, and the component import-boundaries rules as authority.
  • The changeset says SelectorBottomSheet is no longer carried and is deferred, but it is the host that both components still import, so say instead that the bottom-sheet frame (Section, Heading and the sheet markup) leaves the first load and loads with BottomSheet after the first client render.

Non-blocking: rerun node internal/eslint-plugin-astryx/no-internal-barrel-import.baseline.mjs to drop the now-stale rows for SelectorBottomSheet.tsx and Section.tsx, and consider a Selector.ssr.test.tsx like DropdownMenu.ssr.test.tsx, since this change also fixes the bottom-sheet Selector's aborted server render.

Claims and files checked

Review mode: full; reason: author-not-engowner

  • Description: pointer pages no longer carry the sheet frame, Section and Heading in their first load. Verified: Selector's eager entry goes from 108.4 KB to 104.4 KB, and a Selector page loses 4,978 B gzip.
  • Description: about 3.8 KB less (108.4 KB to 104.6 KB). Understated and stale: this head measures 104.4 KB.
  • Description: compact touch and explicit bottom-sheet selectors load the sheet chunk on mount and open as before. Verified: the chunk loads after hydration, and the bottom-sheet tests in Selector.test.tsx and MultiSelector.test.tsx pass.
  • Description: Selector.tsx and MultiSelector.tsx gain a lazy host and a preload Effect. False: neither file changes.
  • Description: SelectorBottomSheet exports its props. Verified (SelectorBottomSheet.tsx:16).
  • Description: SelectorBottomSheet imports BottomSheet directly, with no lazy. False: SelectorBottomSheet.tsx:18 is the lazy, and the direct import is SelectorBottomSheetFrame.tsx:14.
  • Description: the change follows the Tokenizer and PowerSearch pattern under the minimal-DOM styling rule. False citation: it follows the Popover and DropdownMenu sheet hosts under the import-boundaries rules.
  • Description: a preload Effect follows the Effects rule. False: no Effect is added.
  • Description: tests warm the sheet module. Verified (Selector.test.tsx:79-80, MultiSelector.test.tsx:86-87).
  • Description: the bottom-sheet tests pass. Verified for the two files named, but Selector.sheetActiveDescendant.test.tsx fails.
  • Description: the core typecheck passes. Verified.
  • Description: knowledge templates and records are aligned. Verified.
  • Description: the pre-review script reports 0 findings. Not reproduced (it needs a git remote).
  • Changeset: a pointer selector no longer statically carries SelectorBottomSheet. False (Selector.tsx:110, MultiSelector.tsx:112).
  • Changeset: it no longer carries the sheet frame. Verified.
  • Changeset: both components defer SelectorBottomSheet behind a lazy host. False: it is the host.
  • Changeset: the closed sheet loads and mounts after the first client render while the bottom-sheet presentation is active. Verified (SelectorBottomSheet.tsx:25-27, Selector.tsx:2222-2234).
  • Changeset: about 3.8 KB less gzip on first paint. Verified as an understatement (4.0 KB on the entry check, 4,978 B on a Selector page).
  • Changeset: bottom-sheet and compact adaptive selectors load the chunk after mount and open as before. Verified by the bottom-sheet tests.
  • File .changeset/selector-multiselector-defer-selectorbottomsheet-i4zp.md: finding (wrong module named as deferred).
  • File packages/core/src/MultiSelector/MultiSelector.test.tsx: clear.
  • File packages/core/src/Section/Section.tsx: clear (stale lint baseline row, non-blocking).
  • File packages/core/src/Selector/Selector.test.tsx: clear.
  • File packages/core/src/Selector/SelectorBottomSheet.tsx: finding (breaks Selector.sheetActiveDescendant.test.tsx).
  • File packages/core/src/Selector/SelectorBottomSheetFrame.tsx: clear.
  • File scripts/core-single-bundle.test.mjs: clear.

Automated review (maintainer link)

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

Changes requested. The code is ready: a page with one Selector or MultiSelector loads about 4.9 KB less gzip JavaScript on first load, the reference pages are unchanged, and the test and changeset points from the last review are fixed. Two text fixes remain:

  • The pull request description still describes the previous revision (a host and preload Effect in Selector.tsx and MultiSelector.tsx, a direct BottomSheet import in SelectorBottomSheet.tsx, 3.8 KB, and the minimal-DOM rule as authority), so rewrite it for this head: the frame in SelectorBottomSheetFrame.tsx, the host in SelectorBottomSheet.tsx, the Section.tsx import, the bundle-test entry fix, the regenerated lint baseline, the component import-boundaries rules as authority, and Selector's eager entry going from 108.4 KB to 104.4 KB.
  • Miss: the title says SelectorBottomSheet is deferred, but it is the lazy host that both components still import, so retitle the pull request around the frame, for example perf(core): load the Selector bottom-sheet frame on demand (#12018).

Non-blocking: Selector.sheetActiveDescendant.test.tsx:38 adds a consistent-type-imports lint warning (see the inline note), and a Selector.ssr.test.tsx like DropdownMenu.ssr.test.tsx would pin the hydration fix this change also brings.

Claims and files checked

Review mode: full; reason: author-not-engowner

  • Description: pointer selectors no longer carry the sheet frame, Section and Heading in their first load. Verified: both leave Selector's and MultiSelector's eager graph.
  • Description: the base's entry chunk carried BottomSheet. False: BottomSheet was already lazy on the base.
  • Description: about 3.8 KB less (108.4 KB to 104.6 KB). False at this head: 108.4 KB to 104.4 KB, 4.0 KB.
  • Description: compact touch and explicit bottom-sheet selectors load the sheet chunk on mount and open as before. Verified (SelectorBottomSheet.tsx:24-34, Selector.tsx:2222; the bottom-sheet tests pass).
  • Description: Selector.tsx and MultiSelector.tsx gain a lazy host and a preload Effect. False: neither file changes, and no Effect is added.
  • Description: the change follows the Tokenizer and PowerSearch sheet-host pattern under the minimal-DOM styling rule. The pattern is verified; the citation is false, since the component import-boundaries rules govern loading.
  • Description: SelectorBottomSheet exports its props type. Verified (SelectorBottomSheet.tsx:16).
  • Description: SelectorBottomSheet imports BottomSheet directly, with its lazy removed. False: SelectorBottomSheet.tsx:18 is the lazy, and the direct import is SelectorBottomSheetFrame.tsx:14.
  • Description: the tests warm the sheet modules. Verified (Selector.test.tsx:79-80, MultiSelector.test.tsx:86-87).
  • Description: the changeset documents 3.8 KB. False: it says about 4.0 KB.
  • Description: the bottom-sheet tests pass. Verified: all 625 Selector and MultiSelector tests pass.
  • Description: the Core typecheck passes. Verified.
  • Description: knowledge templates and records are aligned. Verified.
  • Description: the pre-review script reports no findings. Not reproduced: it needs a git checkout.
  • Title: SelectorBottomSheet is deferred behind a lazy host. False: it is the host.
  • Changeset: a pointer selector no longer statically carries the bottom-sheet frame (Section, Heading and the sheet markup). Verified.
  • Changeset: the frame loads with BottomSheet after the first client render while the bottom-sheet presentation is active. Verified (SelectorBottomSheet.tsx:24-34, Selector.tsx:2222-2233, MultiSelector.tsx:2495-2506).
  • Changeset: about 4.0 KB less gzip on first paint. Verified (4.0 KB on the entry check; 4,978 B on a Selector page).
  • Changeset: bottom-sheet and compact adaptive selectors load the chunk after mount and open as before. Verified by the bottom-sheet tests.
  • Changeset: a patch bump for Core. Verified (the changeset check passes).
  • File .changeset/selector-multiselector-defer-selectorbottomsheet-i4zp.md: clear.
  • File internal/eslint-plugin-astryx/no-internal-barrel-import.baseline.json: clear (its generator's check passes).
  • File packages/core/src/MultiSelector/MultiSelector.test.tsx: clear.
  • File packages/core/src/Section/Section.tsx: clear.
  • File packages/core/src/Selector/Selector.sheetActiveDescendant.test.tsx: non-blocking lint warning (line 38).
  • File packages/core/src/Selector/Selector.test.tsx: clear.
  • File packages/core/src/Selector/SelectorBottomSheet.tsx: clear.
  • File packages/core/src/Selector/SelectorBottomSheetFrame.tsx: clear.
  • File scripts/core-single-bundle.test.mjs: clear.

Automated review (maintainer link)

@MuhammadAusafJamal MuhammadAusafJamal changed the title perf(core): defer SelectorBottomSheet behind lazy presentation host (#12018) perf(core): load the Selector bottom-sheet frame on demand (#12018) Nov 17, 2026

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

Changes requested: the code is ready, and two sentences in the description need a fix.

  • The description says BottomSheet was eagerly bundled on the base ("no longer eagerly bundle … BottomSheet dependencies" and "previously statically bundled Heading, Section, and BottomSheet"), but the base SelectorBottomSheet.tsx already loaded it through lazy(), so drop BottomSheet from both sentences: the 4.0 KB saving is the frame alone (Section, Heading and the sheet markup).

The sheet test, changeset, title and lint points from the last review are fixed, and the new SSR test fails on the base and passes here. CI has not run on this head yet; a maintainer adds the ci:run label so it runs.

Claims and files checked

Review mode: full; reason: author-not-engowner

  • Description: addresses item 3 of the linked issue (the Selector sheet frame in every Selector's first load). Verified: the frame leaves the Selector and MultiSelector eager graphs.
  • Description: less eager JavaScript before first paint for pointer presentations. Verified: 4,085 B gzip less for the Selector entry and 4,119 B for MultiSelector.
  • Description: pointer consumers no longer eagerly bundle the frame, Section, Heading and BottomSheet. False for BottomSheet, which the base already loaded lazily (SelectorBottomSheet.tsx:18-22 on the base); verified for the frame, Section and Heading.
  • Description: a page using Selector loads 4.0 KB less (108.4 KB to 104.4 KB). Verified (110,955 B to 106,870 B on the import-boundaries entry).
  • Description: compact touch and explicit bottom-sheet selectors load the sheet chunk after mount and open as before. Verified (SelectorBottomSheet.tsx:24-34, Selector.tsx:2222-2233; the bottom-sheet tests pass).
  • Description: SelectorBottomSheet previously bundled Heading, Section and BottomSheet statically. False for BottomSheet (same evidence).
  • Description: the host follows the Popover and DropdownMenu sheet hosts, with a hydration guard and no change to Selector.tsx or MultiSelector.tsx. Verified (Popover/lazyPopoverBottomSheet.ts:46-57, DropdownMenu/lazyMenuBottomSheet.ts:85-96; neither component file changes).
  • Description: the frame and Section import directly, so the lazy graph has no barrel. Verified (SelectorBottomSheetFrame.tsx:14-16, Section.tsx:39; the single-bundle barrel test passes).
  • Description: the component import-boundaries rules are the authority. Verified.
  • Description: the bundle test's code-split walk starts from the app entry. Verified (scripts/core-single-bundle.test.mjs:163).
  • Description: the sheet test holds and warms the frame module. Verified (Selector.sheetActiveDescendant.test.tsx:35-48).
  • Description: the Selector and MultiSelector tests warm the frame. Verified (Selector.test.tsx:79-80, MultiSelector.test.tsx:86-87).
  • Description: the lint baseline drops the stale rows for SelectorBottomSheet.tsx and Section.tsx. Verified; it also drops five other stale rows that its own check requires.
  • Description: the changeset documents a 4.0 KB eager gzip reduction. Verified.
  • Description: the import-boundaries check shows 108.4 KB to 104.4 KB. Verified.
  • Description: the single-bundle test passes 3 of 3. Verified.
  • Description: the sheet, Selector and MultiSelector bottom-sheet tests pass. Verified (658 tests pass).
  • Description: knowledge templates and records are aligned. Verified.
  • Description: public text carries no internal context. Verified.
  • Changeset: a pointer Selector or MultiSelector no longer statically carries the frame (Section, Heading and the sheet markup). Verified.
  • Changeset: the frame loads with BottomSheet after the first client render while the bottom-sheet presentation is active. Verified (SelectorBottomSheet.tsx:25-31).
  • Changeset: about 4.0 KB less gzip on first paint. Verified.
  • Changeset: bottom-sheet and compact adaptive selectors load the chunk after mount and open as before. Verified by the bottom-sheet tests.
  • Changeset: a patch bump for Core. Verified (the changeset check passes).
  • Title: the Selector bottom-sheet frame loads on demand. Verified: it loads only when a bottom-sheet presentation renders.
  • File .changeset/selector-multiselector-defer-selectorbottomsheet-i4zp.md: clear.
  • File internal/eslint-plugin-astryx/no-internal-barrel-import.baseline.json: clear (its check fails on the base and passes here).
  • File packages/core/src/MultiSelector/MultiSelector.test.tsx: clear.
  • File packages/core/src/Section/Section.tsx: clear.
  • File packages/core/src/Selector/Selector.sheetActiveDescendant.test.tsx: clear.
  • File packages/core/src/Selector/Selector.ssr.test.tsx: clear (fails on the base, passes here).
  • File packages/core/src/Selector/Selector.test.tsx: clear.
  • File packages/core/src/Selector/SelectorBottomSheet.tsx: clear.
  • File packages/core/src/Selector/SelectorBottomSheetFrame.tsx: clear.
  • File scripts/core-single-bundle.test.mjs: clear.

Automated review (maintainer link)

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 2b515a0

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

Changes requested: the on-intent sheet load and the earlier fixes hold, but the newest commit ends a held sheet open with its own outside-press listener.

  • useSelectorPresentation.ts (lines 258-280) adds its own document pointerdown listener, stop ref and unmount Effect to end a held sheet open, beside the shared useOutsidePress watch the same hook already uses (line 147), so please start a second watch from useOutsidePress with path => path.includes(trigger) and the trigger's shadow root, and delete the hand-written copy, which already misjudges a second tap on a trigger inside a closed shadow root.
  • The description says the head's Selector boundary entry reads 115.8 to 115.9 KB, but the boundary check on this head reads 116.1 KB (−3.8 KB), so please update that figure.

Ending a held open when the person presses elsewhere or moves focus away fits the import-boundaries record's later-intent rule; only its listener needs to move. The non-blocking notes (held-open arrow keys, no test for a drop by a focus move alone, three tests that warm only BottomSheet, and comment wording) are in the review.

Claims and files checked

Review mode: same-head; reason: none

Claims:

  • Changeset: the bottom-sheet frame no longer loads with the page: verified (SelectorBottomSheet.tsx:27-58, boundary check).
  • Changeset and description: a page with a Selector loads about 4 KB less gzip on first paint: verified (boundary check on this head: −3.8 KB).
  • Changeset: a sheet-presented selector loads the frame on a pointer down, focus or open request: verified (Selector.tsx:2316-2321, :2343; MultiSelector.tsx:2609-2615, :2743; useSelectorPresentation.ts:293).
  • Changeset: a tap before the frame arrives opens the sheet once it does, with focus in the list: verified (Selector.sheetLoad.test.tsx).
  • Popover presentations no longer carry the sheet frame, Section or Heading in their first load: verified (type-only frame import plus import(); boundary check).
  • The trigger also loads on a mouse or pen entering it, and show() loads for the sheet: verified (Selector.tsx:2344, useSelectorPresentation.ts:359-372).
  • A failed load warns once, is not kept, and drops a held open: verified (SelectorBottomSheet.tsx:30-36, moduleLoader.ts:50-62, useSelectorPresentation.ts:293-297, Selector.sheetLoadFailure.test.tsx).
  • The host never suspends, and an early open stays requested until the frame renders it unless the person moves on: verified (SelectorBottomSheet.tsx:53-58).
  • The frame imports BottomSheet, Heading and Section directly, and Section imports mergeProps directly: verified (SelectorBottomSheetFrame.tsx:14-16, Section.tsx:39).
  • During a held open a second press, Enter or Space keeps it while Escape and Tab drop it, and the public hooks keep their signatures: verified (Selector/hooks.ts:476-480, :551-554, :638-641, :655-666; MultiSelector/hooks.ts:97-101, :183-186, :314-317, :337-347).
  • A held open ends on a press outside the trigger or a focus move, and its listeners go when the list shows, on close or on unmount: verified (useSelectorPresentation.ts:243-290, :316, :381-383).
  • The two new held-open tests fail without the change: verified by reading, not run.
  • The loader's new members are additive and no existing caller changes: verified (moduleLoader.ts; MobileNav, DropdownMenu, Toast and Text are untouched).
  • The trigger reports expanded and names the listbox only while the sheet's listbox is in the document; a load elsewhere leaves a closed trigger unchanged; the popover is unchanged; the chevron and its theme state follow: verified (useSelectorPresentation.ts:400-401; Selector.tsx:2249-2250, :2431, :2505, :2513; MultiSelector.tsx:2629-2630, :2826-2832, :2904, :2912).
  • Each new or updated test does what the description says: verified by reading.
  • The lint baseline drops stale rows: verified (lint passes on this head; it also drops other stale rows).
  • After merging main the head's boundary entry reads 115.8 to 115.9 KB: false on this head (116.1 KB).
  • Each of the four reference pages grows under 0.3 KB gzip: verified for this head (the newest commit touches no module those pages reach).
  • The bundle and unit test runs pass: not rechecked here (those jobs run after review).
  • Maintainer device runs at an earlier revision: informational; no record this change touches requires them.

Files:

  • .changeset/selector-multiselector-defer-selectorbottomsheet-i4zp.md: clear
  • internal/eslint-plugin-astryx/no-internal-barrel-import.baseline.json: clear
  • packages/core/src/MultiSelector/MultiSelector.sheetLoad.test.tsx: clear
  • packages/core/src/MultiSelector/MultiSelector.test.tsx: clear
  • packages/core/src/MultiSelector/MultiSelector.tsx: clear
  • packages/core/src/MultiSelector/hooks.ts: clear (comment wording note)
  • packages/core/src/Section/Section.tsx: clear
  • packages/core/src/Selector/Selector.sheetActiveDescendant.test.tsx: clear
  • packages/core/src/Selector/Selector.sheetHeldInputs.test.tsx: clear
  • packages/core/src/Selector/Selector.sheetHeldOtherSelector.test.tsx: clear
  • packages/core/src/Selector/Selector.sheetHeldPressOutside.test.tsx: clear
  • packages/core/src/Selector/Selector.sheetLoad.test.tsx: clear
  • packages/core/src/Selector/Selector.sheetLoadFailure.test.tsx: clear
  • packages/core/src/Selector/Selector.sheetLoadHover.test.tsx: clear
  • packages/core/src/Selector/Selector.ssr.test.tsx: clear
  • packages/core/src/Selector/Selector.test.tsx: clear
  • packages/core/src/Selector/Selector.tsx: clear
  • packages/core/src/Selector/SelectorBottomSheet.tsx: clear
  • packages/core/src/Selector/SelectorBottomSheetFrame.tsx: clear
  • packages/core/src/Selector/__tests__/SelectorSheetHeldOpen.a11y.chromium.spec.ts: clear
  • packages/core/src/Selector/hooks.ts: clear (held-open arrow keys and comment wording, non-blocking)
  • packages/core/src/Selector/useSelectorPresentation.ts: finding (a second outside-press watch beside the shared one)
  • packages/core/src/utils/moduleLoader.test.ts: clear
  • packages/core/src/utils/moduleLoader.ts: clear (doc wording note)

Automated review (maintainer link)

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec d838fa3

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

Changes requested: the held sheet open ends through the shared outside-press watch, as asked earlier, but that watch's default makes a held open swallow a modal host's backdrop tap.

  • useSelectorPresentation.ts (line 260) hands the held-open drop to the shared watch as its outside callback, so the watch records it as a layer's outside close, and a backdrop tap on a Dialog, Drawer or BottomSheet holding the selector, made before the sheet code arrives, leaves that host open; please let the watch skip that count for a close that dismisses no layer, and add a test that the backdrop tap still closes the host.
  • The description says the head's Selector boundary entry reads 116.0 KB, but the boundary check on this head reads 116.1 KB (−3.8 KB), so please update or drop that figure.

The non-blocking notes (a second tap on the chevron re-takes the hold, the held-open arrow keys, test gaps, and comment wording) are in the review.

Claims and files checked

Review mode: same-head; reason: none

Claims:

  • Changeset: the bottom-sheet frame no longer loads with the page: verified (SelectorBottomSheet.tsx:27-37, boundary check).
  • Changeset and description: a page with a Selector loads about 4 KB less gzip on first paint: verified (boundary check on this head: −3.8 KB).
  • Changeset and description: a sheet-presented selector loads the frame on a pointer down, focus or open request, and on a mouse or pen entering the trigger: verified (Selector.tsx:2316-2321, :2343-2346; MultiSelector.tsx:2609-2615, :2743-2746; useSelectorPresentation.ts:288, :354-367).
  • Changeset: a tap before the frame arrives opens the sheet once it does, with focus in the list: verified (Selector.sheetLoad.test.tsx), unless the person presses elsewhere or moves focus first.
  • Popover presentations no longer carry the sheet frame, Section or Heading in their first load: verified (type-only frame import plus import(); boundary check).
  • The bottom sheet was bundled eagerly because the components imported it statically and it imported Heading and Section statically: verified (base SelectorBottomSheet.tsx).
  • A failed load warns once, is not kept, and drops a held open: verified (SelectorBottomSheet.tsx:30-36, moduleLoader.ts, useSelectorPresentation.ts:288-292, Selector.sheetLoadFailure.test.tsx).
  • The host never suspends and renders nothing until the frame arrives, and an early open stays requested until the frame renders it: verified (SelectorBottomSheet.tsx:50-58).
  • The frame imports BottomSheet, Heading and Section directly, and Section imports mergeProps directly: verified (SelectorBottomSheetFrame.tsx:14-16, Section.tsx:39).
  • During a held open a second press, Enter or Space keeps it while Escape and Tab drop it, and the public hooks keep their signatures: verified for a press on the trigger (Selector/hooks.ts:476-480, :551-554, :638-641, :655-666; MultiSelector/hooks.ts:97-101, :183-186, :314-317); a press on the chevron drops and re-takes the hold (non-blocking).
  • A held open ends on a press outside the trigger or a focus move, through a second shared watch and a trigger focus check that stop when the list shows, on close, and (the watch) on unmount: verified (useSelectorPresentation.ts:234-275, :311, :376-378; Layer/outsidePress.ts:300); the drop is also counted as a layer's outside close (blocking finding).
  • The two held-open tests fail without the change: verified by reading, not run.
  • The loader's new members are additive and no existing caller changes: verified (moduleLoader.ts; MobileNav, DropdownMenu, Toast and Text are untouched).
  • The controller owns the listbox attachment and returns one expanded and one named rule for both components: verified (useSelectorPresentation.ts:369-396).
  • The trigger reports expanded and names the listbox only while the sheet's listbox is in the document; a load elsewhere leaves a closed trigger unchanged; the popover is unchanged; a held MultiSelector names no active option; the chevron and its theme state follow: verified (Selector.tsx:2249-2250, :2430-2431, :2505, :2513; MultiSelector.tsx:2629-2630, :2826-2832, :2904, :2912).
  • Each new or updated test does what the description says: verified by reading.
  • The lint baseline drops the stale rows for the sheet host and Section: verified (it also drops six other rows already stale on the base).
  • After merging main the head's boundary entry reads 116.0 KB: false on this head (116.1 KB).
  • Each of the four reference pages grows under 0.3 KB gzip: verified as reported (description table), and consistent with the boundary check's +0.1 KB per entry at this head.
  • The bundle and unit test runs pass: not rechecked (those jobs run after review).
  • The knowledge check passes: verified (the Lint run passes on this head).
  • Maintainer device runs at an earlier revision: informational; no record this change touches requires them.

Files:

  • .changeset/selector-multiselector-defer-selectorbottomsheet-i4zp.md: clear
  • internal/eslint-plugin-astryx/no-internal-barrel-import.baseline.json: clear
  • packages/core/src/MultiSelector/MultiSelector.sheetLoad.test.tsx: clear
  • packages/core/src/MultiSelector/MultiSelector.test.tsx: clear
  • packages/core/src/MultiSelector/MultiSelector.tsx: clear
  • packages/core/src/MultiSelector/hooks.ts: clear (comment wording note)
  • packages/core/src/Section/Section.tsx: clear
  • packages/core/src/Selector/Selector.sheetActiveDescendant.test.tsx: clear
  • packages/core/src/Selector/Selector.sheetHeldInputs.test.tsx: clear
  • packages/core/src/Selector/Selector.sheetHeldOtherSelector.test.tsx: clear
  • packages/core/src/Selector/Selector.sheetHeldPressOutside.test.tsx: clear
  • packages/core/src/Selector/Selector.sheetLoad.test.tsx: clear
  • packages/core/src/Selector/Selector.sheetLoadFailure.test.tsx: clear
  • packages/core/src/Selector/Selector.sheetLoadHover.test.tsx: clear
  • packages/core/src/Selector/Selector.ssr.test.tsx: clear
  • packages/core/src/Selector/Selector.test.tsx: clear
  • packages/core/src/Selector/Selector.tsx: clear
  • packages/core/src/Selector/SelectorBottomSheet.tsx: clear
  • packages/core/src/Selector/SelectorBottomSheetFrame.tsx: clear
  • packages/core/src/Selector/__tests__/SelectorSheetHeldOpen.a11y.chromium.spec.ts: clear
  • packages/core/src/Selector/hooks.ts: clear (held-open arrow keys and comment wording, non-blocking)
  • packages/core/src/Selector/useSelectorPresentation.ts: finding (the held-open drop is counted as a layer's outside close)
  • packages/core/src/utils/moduleLoader.test.ts: clear
  • packages/core/src/utils/moduleLoader.ts: clear (doc wording note)

Automated review (maintainer link)

… so a modal host's backdrop press still closes the host
@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 29d015b

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved pending CI: the held sheet open now ends without counting as a layer's outside close, so a backdrop tap on a Dialog, Drawer or BottomSheet holding the selector closes it in one tap, and the stale boundary figure is gone from the description. The unit, browser, build and docsite jobs are still running on this head, and the merge waits for them to pass.

Nothing blocking remains. The non-blocking notes (a tap on the chevron during a held open drops and re-takes it, the navigation keys tracked in #13751, two missing single-intent tests, three accessibility tests that warm only BottomSheet, and comment wording) are in the review.

Claims and files checked

Review mode: full; reason: author-not-engowner

Claims:

  • Changeset: the bottom-sheet frame (BottomSheet, Section, Heading, sheet markup) no longer loads with the page: verified (SelectorBottomSheet.tsx:22-37, boundary check).
  • Changeset and description: a page using Selector loads about 4 KB less gzip on first paint: verified (boundary check on this head: 120.0 KB to 116.2 KB, −3.8 KB; the description's 118.5 to 114.5 KB pair is from an earlier base, as its evidence section says).
  • Changeset and description: a sheet-presented selector loads the frame when a pointer lands on the trigger, the trigger takes focus, or the list is asked to open, and also when a mouse or pen enters it: verified (Selector.tsx:2319-2321, :2343-2346; MultiSelector.tsx:2612-2614, :2632-2648, :2692-2694, :2743-2746; useSelectorPresentation.ts:290, :356-369).
  • Changeset and description: a tap before the frame arrives opens the sheet once it does, with focus in the list: verified (Selector.sheetLoad.test.tsx), unless the person presses elsewhere or moves focus first.
  • Popover pages no longer carry the frame, Section or Heading in their first load: verified (type-only frame import plus import(); boundary check).
  • The sheet was bundled eagerly because both components imported it statically and it imported Heading and Section statically: verified (the base SelectorBottomSheet.tsx).
  • A failed load warns once, is not kept, and drops a held open: verified (SelectorBottomSheet.tsx:27-37, moduleLoader.ts, useSelectorPresentation.ts:290-294, Selector.sheetLoadFailure.test.tsx).
  • The host never suspends, renders nothing until the frame arrives, and an early open stays requested until the frame renders it: verified (SelectorBottomSheet.tsx:50-58).
  • The frame imports BottomSheet, Heading and Section directly, and Section imports mergeProps directly: verified (SelectorBottomSheetFrame.tsx:14-16, Section.tsx:39).
  • During a held open a second press, Enter or Space keeps it while Escape and Tab drop it, and the public hooks keep their signatures: verified for a press on the trigger (Selector/hooks.ts:476-481, :551-554, :638-641; MultiSelector/hooks.ts:97-102, :183-186, :314-317); a press on the chevron drops and re-takes the hold (non-blocking).
  • A held open ends on a press outside the trigger or a focus move, through a second shared watch that counts no layer dismissal and a trigger focus check; both stop when the list shows or on close, and the watch also on unmount: verified (useSelectorPresentation.ts:234-277, :313, :378-380; Layer/outsidePress.ts:299-315).
  • The outside-press watch gains a dismissal option that defaults to counting, so every existing caller is unchanged: verified (Layer/outsidePress.ts:63-70, :113, :128-130, :201-203).
  • A backdrop press on a Dialog holding the Selector during the hold still closes the Dialog, and the watch's own test covers the option: verified by reading (Selector.sheetHeldBackdrop.test.tsx, outsidePress.test.ts), not run.
  • The press-elsewhere and other-selector tests fail without the change: verified by reading, not run.
  • The loader's new members are additive and no existing caller changes: verified (moduleLoader.ts; MobileNav, DropdownMenu, Toast and Text are untouched).
  • The controller owns the listbox attachment and returns one expanded and one named rule for both components: verified (useSelectorPresentation.ts:371-398).
  • The trigger reports expanded and names the listbox only while the sheet's listbox is in the document; a load elsewhere leaves a closed trigger unchanged; the popover is unchanged; a held MultiSelector names no active option; the chevron and its theme state follow: verified (Selector.tsx:2430-2431, :2505, :2513; MultiSelector.tsx:2709-2710, :2826-2832, :2904, :2912).
  • Each new or updated test does what the description says: verified by reading.
  • The lint baseline drops the stale rows for the sheet host and Section: verified (it also drops six other rows already stale on the base).
  • Each of the four reference pages grows under 0.3 KB gzip: verified as reported, and consistent with the boundary check's +0.1 KB per entry on this head.
  • The bundle and unit test runs pass: not rechecked (those jobs are still running on this head).
  • The knowledge check passes: verified (the Lint run passes on this head).
  • Maintainer device runs at an earlier revision: informational; no record this change touches requires them.

Files:

  • .changeset/selector-multiselector-defer-selectorbottomsheet-i4zp.md: clear
  • internal/eslint-plugin-astryx/no-internal-barrel-import.baseline.json: clear
  • packages/core/src/Layer/outsidePress.test.ts: clear
  • packages/core/src/Layer/outsidePress.ts: clear
  • packages/core/src/MultiSelector/MultiSelector.sheetLoad.test.tsx: clear
  • packages/core/src/MultiSelector/MultiSelector.test.tsx: clear
  • packages/core/src/MultiSelector/MultiSelector.tsx: clear (chevron second-tap note)
  • packages/core/src/MultiSelector/hooks.ts: clear (comment wording note)
  • packages/core/src/Section/Section.tsx: clear
  • packages/core/src/Selector/Selector.sheetActiveDescendant.test.tsx: clear
  • packages/core/src/Selector/Selector.sheetHeldBackdrop.test.tsx: clear
  • packages/core/src/Selector/Selector.sheetHeldInputs.test.tsx: clear
  • packages/core/src/Selector/Selector.sheetHeldOtherSelector.test.tsx: clear
  • packages/core/src/Selector/Selector.sheetHeldPressOutside.test.tsx: clear
  • packages/core/src/Selector/Selector.sheetLoad.test.tsx: clear
  • packages/core/src/Selector/Selector.sheetLoadFailure.test.tsx: clear
  • packages/core/src/Selector/Selector.sheetLoadHover.test.tsx: clear
  • packages/core/src/Selector/Selector.ssr.test.tsx: clear
  • packages/core/src/Selector/Selector.test.tsx: clear
  • packages/core/src/Selector/Selector.tsx: clear (chevron second-tap note)
  • packages/core/src/Selector/SelectorBottomSheet.tsx: clear
  • packages/core/src/Selector/SelectorBottomSheetFrame.tsx: clear
  • packages/core/src/Selector/__tests__/SelectorSheetHeldOpen.a11y.chromium.spec.ts: clear
  • packages/core/src/Selector/hooks.ts: clear (held-open navigation keys and comment wording, non-blocking)
  • packages/core/src/Selector/useSelectorPresentation.ts: clear (comment wording notes)
  • packages/core/src/utils/moduleLoader.test.ts: clear
  • packages/core/src/utils/moduleLoader.ts: clear (doc wording note)

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as draft November 25, 2026 00:52
@cixzhang
cixzhang marked this pull request as ready for review November 25, 2026 00:53
@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 748d997

@cixzhang
cixzhang marked this pull request as draft November 25, 2026 07:03
@cixzhang
cixzhang marked this pull request as ready for review November 25, 2026 07:04

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved pending CI: the bottom-sheet frame now loads on the trigger's intent, a tap made before it arrives is held with the trigger reading collapsed, and the merge of main changes none of this pull request's own lines. The unit, build, browser and docsite jobs started on this head after review passed and are still running; the merge waits for them to pass.

Nothing blocking remains. The non-blocking notes (a tap on the chevron during a held open drops and re-takes it, the navigation keys tracked in #13751, two missing single-intent tests, three accessibility tests that warm only BottomSheet, and comment wording) are unchanged from the last review.

Claims and files checked

Review mode: full; reason: author-not-engowner

Claims:

  • Changeset: the bottom-sheet frame (BottomSheet, Section, Heading, sheet markup) no longer loads with the page: verified (SelectorBottomSheet.tsx:22-37, boundary check).
  • Changeset and description: a page using Selector loads about 4 KB less gzip on first paint: verified (boundary check on this head: 120.3 KB to 116.5 KB, −3.8 KB; the description's 118.5 to 114.5 KB pair is from an earlier base, as its evidence section says).
  • Changeset and description: a sheet-presented selector loads the frame when a pointer lands on the trigger, the trigger takes focus, or the list is asked to open, and also when a mouse or pen enters it: verified (Selector.tsx:2326-2328, :2350-2353; MultiSelector.tsx:2619-2621, :2642-2655, :2699-2701, :2750-2753; useSelectorPresentation.ts:290, :356-369).
  • Changeset and description: a tap before the frame arrives opens the sheet once it does, with focus in the list: verified (Selector.sheetLoad.test.tsx), unless the person presses elsewhere or moves focus first.
  • Popover pages no longer carry the frame, Section or Heading in their first load: verified (type-only frame import plus import(); boundary check).
  • The sheet was bundled eagerly because both components imported it statically and it imported Heading and Section statically: verified (the base SelectorBottomSheet.tsx).
  • A failed load warns once, is not kept, and drops a held open: verified (SelectorBottomSheet.tsx:27-37, moduleLoader.ts:50-83, useSelectorPresentation.ts:290-294, Selector.sheetLoadFailure.test.tsx).
  • The host never suspends, renders nothing until the frame arrives, and an early open stays requested until the frame renders it: verified (SelectorBottomSheet.tsx:50-59).
  • The frame imports BottomSheet, Heading and Section directly, and Section imports mergeProps directly: verified (SelectorBottomSheetFrame.tsx:14-16, Section.tsx:39).
  • During a held open a second press, Enter or Space keeps it while Escape and Tab drop it, and the public hooks keep their signatures: verified for a press on the trigger (Selector/hooks.ts:476-481, :551-554, :638-641; MultiSelector/hooks.ts:97-102, :183-186, :314-317); a press on the chevron drops and re-takes the hold (non-blocking).
  • A held open ends on a press outside the trigger or a focus move, through a second shared watch that counts no layer dismissal and a trigger focus check; both stop when the list shows or on close, and the watch also on unmount: verified (useSelectorPresentation.ts:234-277, :313, :378-380; Layer/outsidePress.ts:299-318).
  • The outside-press watch gains a dismissal option that defaults to counting, so every existing caller is unchanged: verified (Layer/outsidePress.ts:63-70, :113, :128-130, :201-203).
  • A backdrop press on a Dialog holding the Selector during the hold still closes the Dialog, and the watch's own test covers the option: verified by reading (Selector.sheetHeldBackdrop.test.tsx, outsidePress.test.ts), not run.
  • The press-elsewhere and other-selector tests fail without the change: verified by reading, not run.
  • The loader's new members are additive and no existing caller changes: verified (moduleLoader.ts; MobileNav, DropdownMenu, Toast and Text are untouched).
  • The controller owns the listbox attachment and returns one expanded and one named rule for both components: verified (useSelectorPresentation.ts:371-398).
  • The trigger reports expanded and names the listbox only while the sheet's listbox is in the document; a load elsewhere leaves a closed trigger unchanged; the popover is unchanged; a held MultiSelector names no active option; the chevron and its theme state follow: verified (Selector.tsx:2437-2438, :2512, :2520; MultiSelector.tsx:2716-2717, :2833-2839, :2911, :2919).
  • Each new or updated test does what the description says: verified by reading.
  • The lint baseline drops the stale rows for the sheet host and Section: verified (it also drops six other rows already stale on the base).
  • Each of the four reference pages grows under 0.3 KB gzip: verified as reported, and consistent with the boundary check's +0.1 KB per entry on this head.
  • The bundle and unit test runs pass: not rechecked (those jobs are still running on this head).
  • The knowledge check passes: verified (the Lint run passes on this head).
  • Maintainer device runs at an earlier revision: informational; no record this change touches requires them.

Files:

  • .changeset/selector-multiselector-defer-selectorbottomsheet-i4zp.md: clear
  • internal/eslint-plugin-astryx/no-internal-barrel-import.baseline.json: clear
  • packages/core/src/Layer/outsidePress.test.ts: clear
  • packages/core/src/Layer/outsidePress.ts: clear
  • packages/core/src/MultiSelector/MultiSelector.sheetLoad.test.tsx: clear
  • packages/core/src/MultiSelector/MultiSelector.test.tsx: clear
  • packages/core/src/MultiSelector/MultiSelector.tsx: clear (chevron second-tap note)
  • packages/core/src/MultiSelector/hooks.ts: clear (comment wording note)
  • packages/core/src/Section/Section.tsx: clear
  • packages/core/src/Selector/Selector.sheetActiveDescendant.test.tsx: clear
  • packages/core/src/Selector/Selector.sheetHeldBackdrop.test.tsx: clear
  • packages/core/src/Selector/Selector.sheetHeldInputs.test.tsx: clear
  • packages/core/src/Selector/Selector.sheetHeldOtherSelector.test.tsx: clear
  • packages/core/src/Selector/Selector.sheetHeldPressOutside.test.tsx: clear
  • packages/core/src/Selector/Selector.sheetLoad.test.tsx: clear
  • packages/core/src/Selector/Selector.sheetLoadFailure.test.tsx: clear
  • packages/core/src/Selector/Selector.sheetLoadHover.test.tsx: clear
  • packages/core/src/Selector/Selector.ssr.test.tsx: clear
  • packages/core/src/Selector/Selector.test.tsx: clear
  • packages/core/src/Selector/Selector.tsx: clear (chevron second-tap note)
  • packages/core/src/Selector/SelectorBottomSheet.tsx: clear
  • packages/core/src/Selector/SelectorBottomSheetFrame.tsx: clear
  • packages/core/src/Selector/__tests__/SelectorSheetHeldOpen.a11y.chromium.spec.ts: clear
  • packages/core/src/Selector/hooks.ts: clear (held-open navigation keys and comment wording, non-blocking)
  • packages/core/src/Selector/useSelectorPresentation.ts: clear (comment wording notes)
  • packages/core/src/utils/moduleLoader.test.ts: clear
  • packages/core/src/utils/moduleLoader.ts: clear (doc wording note)

Automated review (maintainer link)

@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Nov 25, 2026
@cixzhang
cixzhang merged commit c5176c1 into meta:main Nov 25, 2026
221 of 227 checks passed
@cixzhang

Copy link
Copy Markdown
Contributor

🤖 (Posted by Cindy's agent.) Merged, thank you @MuhammadAusafJamal! Selector and MultiSelector now load their bottom-sheet code only when someone is about to open one (on hover, focus or the first press), so pages with a Selector download about 4 KB less up front. Along the way, the change picked up careful handling for slow and failed loads: a tap made while the sheet loads opens it exactly once, tapping elsewhere cancels it, and a failed load leaves the Selector usable and retries on the next tap. A maintainer carried the later rounds on your branch with you credited. Thank you for starting this.

@MuhammadAusafJamal

Copy link
Copy Markdown
Contributor Author

🤖 (Posted by Cindy's agent.) Merged, thank you @MuhammadAusafJamal! Selector and MultiSelector now load their bottom-sheet code only when someone is about to open one (on hover, focus or the first press), so pages with a Selector download about 4 KB less up front. Along the way, the change picked up careful handling for slow and failed loads: a tap made while the sheet loads opens it exactly once, tapping elsewhere cancels it, and a failed load leaves the Selector usable and retries on the next tap. A maintainer carried the later rounds on your branch with you credited. Thank you for starting this.

Thank you for letting me be a part of this project. ;)

This branch was successfully deployed

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

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) CLA Signed This label is managed by the Meta Open Source bot. community Authored by a community contributor (not on the eng/design team) lane:2 Astryx fix-loop lane 2 owns this needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants