Repository navigation
feat(core)!: default Selector, MultiSelector, and DropdownMenu to adaptive presentation - #6819
thedjpetersen wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report
Modified ComponentsMoreMenu (@astryxdesign/core)
Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Visual Regression15 of 420 shot(s) changed. A change here is a question, not a failure: check whether the after is the
Generated by PR Enrichment workflow | View full report |
…ptive presentation Need: Selector, MultiSelector, and data-driven DropdownMenu defaulted to `presentation="popover"`. On a phone, a call site that did not know to opt in opened a mouse-sized list anchored to the trigger. In a 390px touch viewport the default Selector list covered the field's own label, helper text, and the next card. The default DropdownMenu opened a 97px-wide menu with 32px rows, and every label in it was truncated. The `adaptive` surface already existed for all three components, and the date inputs already pick their surface from the device, but only callers who knew to ask for it got it. Model: when `presentation` is omitted, Selector and MultiSelector resolve `adaptive`, and so does DropdownMenu when it gets `items`. `adaptive` uses the shared compact-touch query, `(max-width: 768px) and (pointer: coarse)`: a modal BottomSheet on a phone, the anchored popover everywhere else. MoreMenu forwards to DropdownMenu, so it follows. Compound (children) DropdownMenus stay anchored, and an explicit `presentation` always wins. The prop docs, JSDoc, consumer examples, the adaptive DropdownMenu block, and the Storybook controls now describe the default. Compatibility: no type changes, but a stable default changes, so the changeset is [breaking] (minor while 0.x). Mouse, trackpad, and larger touch screens render exactly what they rendered before (the 1440px screenshots are byte-identical). On compact touch screens the default becomes a modal dialog: the trigger reports `aria-haspopup="dialog"`, focus moves into the sheet, and it returns to the trigger on close. Pass `presentation="popover"` to keep the anchored list for a specific control.
cb43a69 to
93db453
Compare
|
Based on Ruby’s feedback, I’d prefer to keep the current default presentation unchanged and make the popover wider when its content is long. |
There was a problem hiding this comment.
Approval is on hold for an owner decision, and five fixes are needed either way.
Owner decision: the Selector spec on main makes adaptive the default (DEC-1), but the MultiSelector, DropdownMenu and MoreMenu specs, which became current on main after the last review, keep popover; DEP-0011 lists those defaults as open, and a maintainer commented here that they prefer popover with a wider popover. An engineering owner either withdraws DEC-1, and this PR closes, or updates those three records to make adaptive their default and records the decision with /approve-spec <full head SHA> on the pull request; the author may do so as an engineering owner.
Required changes:
- Newly live check: the Selector
presentationdefault change is outside this pull request's declared scope, because the title'scorescope names no component and## Scopehas noComponents:line; name Selector in the scope. - Newly live check: the MultiSelector
presentationdefault change is outside this pull request's declared scope for the same reason; name MultiSelector in the scope. - Newly live check: the DropdownMenu
presentationdefault change is outside this pull request's declared scope for the same reason; name DropdownMenu in the scope. - Newly live check: the MoreMenu
presentationdefault change is outside this pull request's declared scope for the same reason; name MoreMenu in the scope. - Newly live check: the two
AdaptiveByDefaultstories copy the compact-touch query (Selector.stories.tsx:177,DropdownMenu.stories.tsx:1096) instead of relying on the component's own resolver, which on main already answers differently, so drop the copied query and the device line.
Before merge, rebase onto main and wait for main to declare a minor so the [breaking] Changeset can merge; in the rebase, describe main's compact definition in place of "768px or narrower" and name the Pagination, PowerSearch and Table selectors, which have no opt-out.
Important
Owner decisions needed before merge. This changes a stable default on phones, so the changeset is
[breaking](a 0.x minor) and needs the component owner's approval and a slot in the next minor release plan. The current Selector spec still says the default ispopover, so the specification amendment, #6809, must land first. Details under "Owner and specification decisions needed" below.On a phone, Selector, MultiSelector, and DropdownMenu open a small mouse-sized list anchored to the trigger unless the caller knows to opt in. That list covers the field it belongs to and the content below it, or it gets squeezed until every label is cut off. This PR makes the existing adaptive mode the default: phones get a full-width bottom sheet, and mouse, trackpad, and larger touch screens keep the popover they have today.
At a glance
presentation="popover"keeps the old surface on any device.[breaking](minor). It needs owner sign-off and the Selector spec amendment, both included.Core/SelectorandCore/DropdownMenu, each under "Presentation / adaptive by default".Second view: Side-by-side 390px phone screenshots after tapping the Shipping speed selector
Every screenshot, measurement file and repro script for this PR: astryx-pr-evidence/menus-adaptive
Primary intent
When a caller does not pass
presentation, Selector, MultiSelector, and data-driven DropdownMenu should adapt to phones. On a compact touch screen they open in a modal bottom sheet. On every other device they open in the anchored popover, exactly as they do today.This is one intent: the zero-config default of the shared
presentationvocabulary. It is not three independent fixes. All three components already implementadaptivethrough the sameuseAdaptivePresentationpolicy and the same query,(max-width: 768px) and (pointer: coarse). Each change is one line, and all three share one owner decision and one release entry. Landing only some of them would recreate the inconsistency this PR removes: a phone page where the selectors adapt and the action menus don't, or the reverse. MoreMenu isn't a separate delta. It forwardspresentationto DropdownMenu, so it inherits the default, and its docs change only to state that.User or maintainer impact
items), or MoreMenu is used on a phone and doesn't setpresentation. That includes controls composed inside other components: the Pagination page-size selector, Table filter selectors, PowerSearch value editors, and the lab Schedule view menu.aria-haspopup="dialog", focus moves into the sheet, and it returns to the trigger on close.presentationalways wins.Problem and solution fit
Why does it occur?
presentationdefaults topopoveron all three components.adaptivehas shipped for a while, but it's opt-in. A caller who doesn't know to ask for it, and most don't, gets the mouse surface on a phone. The DropdownMenu JSDoc example even told callers to write their own media query (presentation={useBottomSheet ? 'bottom-sheet' : 'popover'}).Why does that harm the task? In a 390px touch viewport, the default Selector's list lays the selected row over the trigger. It covers the field's label, the trigger, and the helper text, plus 69px of the next card. The default DropdownMenu opens as a 97px-wide popover, clamped to the space between the trigger and the viewport edge. All four of its labels are truncated ("Edit or…", "Duplic…") and its rows are 32px tall, under the 44px touch target used elsewhere.
Why does that matter? These are among the most-used components. In a blind agent-built UI benchmark (three AI coding models one-shot built 24 real product screens, and two model judges scored screenshots at 1440px and on a 390px phone), Selector appeared in 40% of Astryx builds and DropdownMenu in 52%. "Panels covering content" was 8.8% of all judge notes on Astryx pages, and "clipped or wrapping buttons and controls" was 5.8%. The date inputs already pick their surface from the device, so a page mixed device-aware pickers with mouse-only menus. Changing the default fixes every call site at once, including composed ones, with no new API and no media query at the call site.
Delta map
presentation = 'adaptive'default inSelector.tsxandMultiSelector.tsx;?? 'adaptive'foritemsinDropdownMenu.tsx@defaultand prop docs in Selector, MultiSelector, DropdownMenu, and MoreMenu (en and zh)'popover', which is wrong once DropdownMenu's default changes.adaptive. It now says to keep the default and pinpopoveronly when product policy needs it.DropdownMenuJSDoc example; theDropdownMenu — Adaptive presentationCLI blockhover: nonepolicy). That is redundant now and teaches the wrong pattern, so both rely on the default.Selector.doc.mjsandDropdownMenu.doc.mjsAdaptiveByDefaultstories;adaptiveadded to DropdownMenu's control optionsapps/docsite/src/__tests__/data-extraction.test.ts)popoverdefault and the hand-wired media query in the DropdownMenu block. They now assert theadaptivedefault, that the block wires no media query, and that it is no longer cross-listed on theuseMediaQuerypage.No tagalongs. Explicitly left out:
popover.adaptivequery itself: still width plus coarse pointer, not the date inputs' pointer-only test (seespec:AST-043OQ1).popovermenu near the viewport edge: a separate defect.Representative callsite (unchanged source, new result on phones)
Caller decisions added: none for new code. Existing code that relies on the anchored list on phones must add
presentation="popover". No codemod is provided, because rewriting every call site topopoverwould undo the change for every project that runsastryx upgrade --apply.Authority
component:Selector(current): its Compatibility section says "presentationdefaults topopover" and its Public concepts table listspopoveras the default. FR4, which defines what each value does, is unchanged. This PR contradicts that current claim, so the spec amendment below must be approved and merged before this PR (or at the same exact head). Proposed amendment, ready to apply: spec(Selector): record adaptive as the default presentation (DEC-1) #6809. It runspnpm check:knowledgeclean after applying. It:adaptiveadaptive, or explicitbottom-sheet"presentationdefault that DEC-1 changes"DEC-1 — Default presentation is adaptive, whose rejected alternatives are: keeppopover; switch to a pointer-only query; ship a codemod that pinspopovercomponent:MultiSelectorandcomponent:DropdownMenu: both are draft, so no amendment is required. DropdownMenu's "Released default preserved: yes" line describes that draft's own documentation-only scope.spec:AST-043(current), the date/time input presentation spec. The date inputs default to a device-adaptive surface (adaptive-native). An explicit value always renders the named surface (FR1 forced values), and docs, types, and Storybook controls show the values and default (FR5). This PR applies the same three rules to the menu and selector vocabulary. It doesn't renameadaptive(AST-043 OQ1, out of scope) and doesn't change the queryadaptiveresolves against.family:input-fields: Selector and MultiSelector. No family claim covers popup surface choice.family:overlay-dismissal: all three. Both surfaces already participate. The record notes "Adaptive BottomSheet paths inherit BottomSheet's adoption gap" (BottomSheet's dismissal is still local). This PR makes that path the phone default, so I verified nested dismissal in a real browser (below): Escape and selection close only the sheet, not a surrounding Dialog or Popover.spec:AST-017(current). FR3 counts defaults and documented interaction behavior as released contract. On compact touch this switches a stable default and the popup semantics (listbox or menu to modal dialog), so the changeset is[breaking], a minor bump while on 0.x, as CONTRIBUTING requires for stable default changes. FR31 allows a default switch only through an approved lifecycle id pair in a frozen minor plan.Change and evidence
Tests (fail before, pass after). 15 new or rewritten tests in
default presentationblocks. Each file answers only the sharedCOMPACT_TOUCH_PRESENTATION_QUERY, so the tests track the policy the component actually reads.aria-haspopup="dialog")popoverstays anchored on compact touchpopoveron compact touchitemsmenu opens a BottomSheet on compact touchpopover/ compound menu on compact touchpopoverstays anchored on compact touchBefore: 7 failed, 8 passed (the 8 are the unchanged paths). After: 15 passed. RTL and dark mode are not involved: no logical properties or colors change, and the sheet and popover surfaces are untouched.
Real-browser measurements. Scratch Vite app using the Neutral theme. Chromium, 390×844 with
isMobileandhasTouch(the compact-touch query matches), and 1440×900 with a mouse (it doesn't). "Before" is theorigin/mainbuild and "after" is this head. The page is an order screen with a "Shipping speed" Selector and an "Actions" DropdownMenu. The raw data is in evidence/{before,after}-{measure,probe,aria-390}.json.aria-haspopup/ accessible nameslistbox/ listbox unnameddialog/ dialog and listbox both named "Shipping speed"menu"Actions" withmenuitemsdialog"Actions" with buttons (the existing bottom-sheet presentation)Keyboard and focus (real browser, after).
aria-activedescendant, and ArrowDown moves betweenmenuitems.Composition (real browser, 390 touch).
purpose="form"Dialog: Escape closes only the sheet and leaves the Dialog open. Picking "Overnight" commits the value and leaves the Dialog open.onClick. No page errors in any state.Evidence images (to drag in):
Preview stories:
Core/Selector→ Presentation / adaptive by default (AdaptiveByDefault)Core/DropdownMenu→ Presentation / adaptive by default (AdaptiveByDefault)Each story shows 320px, 390px, and wide frames with the default component, plus a line saying which surface this device resolves to. Frame width alone doesn't switch the surface. Open the story on a phone, or in device emulation with touch, to see the sheet.
Consumer examples (
astryx component Selector/astryx component DropdownMenu):Global-baseline review receipt (regenerated at this head; 38 matched claims)
Review receipt. Produced by
node scripts/review-global-baselines.mjs --authority-commit 217f41d74ec41aee7f6895ea53e8b6035831f3b7 --review-head cb43a696596ab81c81dfa97fb0691aef55bf51f5 --triggers public-api,behavior,accessibility. It returned 41 matches (the full JSON is inreview-receipt.txt):public-api(reason: requested trigger matched the review-applicability:v1 claim).architecture:public-component-api[breaking], and gated on an owner decision.adaptivekeeps its existing meaning.spec:AST-002architecture:container-paddingINV3, INV7, INV9, INV10, INV11: no delta. No padding or bleed surface changes.accessibility(reason: requested trigger matched the review-applicability:v1 claim).spec:AST-020spec:AST-009menu/menuitemtodialogwith buttons, and Selector from listbox popup to modal dialog containing the listbox). This PR claims no new announcement or mode behavior. It reuses the existingbottom-sheetsemantics already shipped behind explicitpresentation, so I did not run a mobile screen reader. See owner decisions.behavior: no global claim matched. The direct owners govern, as listed under Authority.Owner and specification decisions needed (plain):
component:Selectoris current and sayspopover. If approved, merge spec(Selector): record adaptive as the default presentation (DEC-1) #6809 as its own specification PR, filling in theDEC-1decider and date, before or at this PR's exact head. If rejected, close this PR. There is no partial version worth landing.spec:AST-017FR3/FR31 this is a stable default switch. The changeset is[breaking](minor), and the release plan needs to assign its lifecycle and cleanup ids.spec:AST-009FR3/FR13, run VoiceOver with iOS Safari on the two stories before merge.spec:AST-043OQ1. If menus later renameadaptivetoadaptive-bottom-sheet, this default renames with it under that deprecation.Scope
Testing
Commands run, all from the repo root with Node 24 unless noted:
npx vitest run --root . packages/core/src/{Selector/Selector,MultiSelector/MultiSelector,DropdownMenu/DropdownMenu}.test.tsx packages/core/src/MoreMenu -t "default presentation"with the three source files reset toorigin/main. Result: 7 failed, 8 passed.npx vitest run --root . packages/core/src/Selector packages/core/src/MultiSelector packages/core/src/DropdownMenu packages/core/src/MoreMenu packages/core/src/docPropLiterals.test.ts packages/core/src/docPropReferences.test.ts packages/core/src/docs-script.test.mjs. Result: 13 files, 572 passed.npx vitest run --root . packages/cli/api/template packages/cli/authoring/doctypes/template packages/cli/clients/cli/commands/{component-package,external-showcase}.test.mjs packages/cli/foundation/doc-compiler/inputs.test.mjs packages/cli/test/{golden-reads,doc-routes,docs-graph,invalid-component-metadata.regression}.test.mjs. Result: 19 files, 173 passed.npx vitest run --root . packages/core. Result: 359 files, 10664 passed, no unhandled errors.pnpm -F @astryxdesign/core typecheck: clean.pnpm -F @astryxdesign/core typecheck:docs: clean.pnpm -F @astryxdesign/cli typecheck:template-docs: clean.pnpm -F @astryxdesign/storybook typecheck: 0 errors in the touched stories. 41 errors elsewhere: 38 are theme and vega workspace packages that aren't built in this checkout, and 3 are chart-story implicit-any errors that follow from them; the error list is identical onorigin/main(diffed).pnpm check:repo: passes, also through the pre-commit hook.node packages/cli/clients/cli/bin/astryx.mjs component Selector --denseandcomponent DropdownMenu --dense: the new examples render.pnpm buildatorigin/mainand at head, overlaid into the scratch Vite app, then Playwrightshoot.cjs(screenshots and measurements),probe.cjs(keyboard, focus, and composition),a11y.cjs(ARIA snapshots), and sharpcompare.cjs.Note
Rebased onto
main@217f41dwith no conflicts. At this head, the focused tests, core typecheck, ESLint andcheck:repowere re-run and pass, and the global-baseline receipt was regenerated (same matched claims). Screenshots and measurements were captured againstmain@eedc844; the regression tests that encode them pass at this head.