Repository navigation
feat(menu): modernize Menu to Material Design 3 specs - #5073
mikolajadamowicz wants to merge 15 commits into
Conversation
MikitasK
left a comment
There was a problem hiding this comment.
thanks for addressing all my #5037 comments, nothing else from my side 👌
just make sure to cover all @JKobrynski comments before merging the PR
|
This is in for 6.0 with your In the same pass, please drop the props that look internal, since removing a public prop after 6.0.0 is breaking (we can add them later if asked):
If you can't get to it, let us know and someone on the team can take it over, keeping your commits. |
Removed:
Added:
TODO: |
|
Thanks Oskar, the props we asked to drop are gone. Before review:
|
Menu.Item used fixed 48dp height with two-line supporting text and a content minWidth that collapsed trailingSupportingText to zero width. Use minHeight + padding for supporting rows, intrinsic row sizing for trailing slots, and showcase the vibrant color scheme in the example.
Thanks! Dropped the |
PR description
Motivation
Modernize
Menu/Menu.Itemto the latest Material Design 3 specs. Reuse theme tokens (shape, typography, motion, color roles) and extract component tokens in the same pattern as Checkbox / FAB / ConnectedButtonGroup.Spec re-check (M3 menus)
Re-checked M3 menus specs and overview:
surfaceContainerLow. Theelevationprop controls shadow only (Paper'selevation.level2maps to different surfaceContainer tones, so it is not used as the menu fill).colorScheme="vibrant"onMenuandMenu.Item.Changes
Tokens / Menu / Menu.Item
Menu/tokens.tswith sizes, shapes, typography and color roles for both schemessurfaceContainerLow; surfacecorner.large; first/last/selected itemcorner.mediumapplied through a layout context (composeMenuChildren+context.tsx) — nocloneElement, nodisplayNamefilteringMenu.ItemgainssupportingText,trailingSupportingText,selected,colorScheme,roundedTop/roundedBottom, matchingsupportingTextStyle/trailingSupportingTextStyle, andsupportingTextMaxFontSizeMultiplier/trailingSupportingTextMaxFontSizeMultiplierlabelLarge; selected items use tertiary roles, withdisabledwinning overselectedvia content opacityMenu/motion.ts: spring open/close driven bytoRawSpring, snapping instead when reduce-motion is oncolorSchemeonMenu:standard|vibrantExample / docs / tests
Test infrastructure
jest/setNodeEnv.jssetsNODE_ENV=testbefore React Native loads, soAnimatedforce-updates host styles andtoHaveStylecan see themjest/testSetup.jsstubsAnimated.springthe same wayAnimated.timingwas already stubbed, so native-driver animations don't fail under JestReview feedback from #5037
All five inline comments from @MikitasK are addressed:
Menu.Itemnow falls back toMenuRootContextforcolorScheme, so items rendered inside a wrapper orFragment— which never receiveMenuItemLayoutContext— no longer drop back tostandardinside a vibrant menusupportingTextandtrailingSupportingTextuse explicit presence flags instead of truthiness, so numeric values such as0render while boolean placeholders stay ignoredtrailingSupportingTextgrow with their content instead of keeping a fixed 48/32dp height, which previously clipped at large accessibility font sizesEach fix has a regression test that fails without it.
Two further accessibility / spec fixes
Found while verifying the above on device:
maxFontSizeMultiplier, the two supporting texts passed nothing, so at accessibility sizes they outgrew the title they belong to and truncated. AddedsupportingTextMaxFontSizeMultiplierandtrailingSupportingTextMaxFontSizeMultiplier, both defaulting to1.5to match the title. Naming follows the existingListItempair.⌘Csat next to the label rather than at the menu edge where M3 puts it. The row now stretches and the trailing text uses an auto left margin. Menu width is unchanged.Related issue
Fixes #4977
Test plan
yarn typecheck/yarn lint/ full unit test suite green (55 suites, 762 tests, 169 snapshots)tsc --noEmitVisual verification