diff --git a/docs/6.x/docs/guides/migration.md b/docs/6.x/docs/guides/migration.md index 322a7c3596..c348ee3c70 100644 --- a/docs/6.x/docs/guides/migration.md +++ b/docs/6.x/docs/guides/migration.md @@ -261,7 +261,7 @@ In 5.x, each of these components multiplied `roundness` by a fixed number, and t | Role | Default | 5.x multiplier | Components | | ---------------- | ------- | -------------- | --------------------------------------------------- | -| `extraSmall` | 4 | 1 | `Menu`, `Snackbar`, `Tooltip` | +| `extraSmall` | 4 | 1 | `Snackbar`, `Tooltip` | | `small` | 8 | 2 | `Chip` | | `medium` | 12 | 3 | `Card` | | `largeIncreased` | 20 | 5 | `SegmentedButtons` | @@ -921,8 +921,14 @@ The `overlayAccessibilityLabel` prop was renamed to `dismissAccessibilityLabel`: ``` +`Menu` and `Menu.Item` now follow the Material Design 3 menu specs. The surface is `surfaceContainerLow` instead of `theme.colors.elevation.level2`. The `elevation` prop is unchanged but now only sets the shadow; it no longer changes the fill color. Its corners are 16dp instead of 4dp. To change the fill, override `surfaceContainerLow` in your theme. Item titles use `labelLarge` instead of `bodyLarge`, and items have 4dp corners, or 12dp when `selected`. + +New: `Menu` takes `colorScheme` (`standard` or `vibrant`), and `Menu.Item` takes `selected`, `supportingText` and `trailingSupportingText`. + On web, a menu now closes on the Escape key when it is pressed down, instead of when it is released. Back and Escape dismiss only the topmost overlay, so a menu opened from a `Modal` or `Dialog` closes first and leaves the modal open. +On Android, opening a menu now moves screen reader focus to its first enabled item, and closing it moves focus back to the anchor. With a hardware keyboard, the Up and Down arrow keys move between the enabled items and skip disabled ones. Moving keyboard focus into the menu when it opens also needs React Native's `enableImperativeFocus` feature flag, which is off by default; without it, TalkBack still works, but the keyboard focus stays where it was. + On Android, an open menu now also keeps the back press: it calls `onDismiss`, and the screen behind no longer goes back. Previously the press reached that screen as well. Without an `onDismiss`, the menu leaves the press to whatever is underneath, so pass one to close the menu on back. ### Searchbar @@ -1685,11 +1691,7 @@ For `tonal`, toggle-on draws `secondary` with an `onSecondary` icon, and toggle- ( - + )} /> ``` diff --git a/docs/public/screenshots/menu-0.png b/docs/public/screenshots/menu-0.png new file mode 100644 index 0000000000..ae8946fdd7 Binary files /dev/null and b/docs/public/screenshots/menu-0.png differ diff --git a/docs/public/screenshots/menu-1.png b/docs/public/screenshots/menu-1.png index babbd17e84..fd308dc6a9 100644 Binary files a/docs/public/screenshots/menu-1.png and b/docs/public/screenshots/menu-1.png differ diff --git a/docs/public/screenshots/menu-2.png b/docs/public/screenshots/menu-2.png index 313453f353..5a2d0c96ef 100644 Binary files a/docs/public/screenshots/menu-2.png and b/docs/public/screenshots/menu-2.png differ diff --git a/docs/public/screenshots/menu-3.png b/docs/public/screenshots/menu-3.png new file mode 100644 index 0000000000..f3c68e9f02 Binary files /dev/null and b/docs/public/screenshots/menu-3.png differ diff --git a/docs/public/screenshots/menu-4.png b/docs/public/screenshots/menu-4.png new file mode 100644 index 0000000000..88235c92a9 Binary files /dev/null and b/docs/public/screenshots/menu-4.png differ diff --git a/docs/public/screenshots/menu-ios-bottom.png b/docs/public/screenshots/menu-ios-bottom.png new file mode 100644 index 0000000000..2e405da0f2 Binary files /dev/null and b/docs/public/screenshots/menu-ios-bottom.png differ diff --git a/docs/public/screenshots/menu-ios-closed.png b/docs/public/screenshots/menu-ios-closed.png new file mode 100644 index 0000000000..e6abb0461c Binary files /dev/null and b/docs/public/screenshots/menu-ios-closed.png differ diff --git a/docs/public/screenshots/menu-ios-icons.png b/docs/public/screenshots/menu-ios-icons.png new file mode 100644 index 0000000000..b3d2455bee Binary files /dev/null and b/docs/public/screenshots/menu-ios-icons.png differ diff --git a/docs/public/screenshots/menu-ios-selected.png b/docs/public/screenshots/menu-ios-selected.png new file mode 100644 index 0000000000..1fe4b254e2 Binary files /dev/null and b/docs/public/screenshots/menu-ios-selected.png differ diff --git a/docs/public/screenshots/menu-ios-vibrant.png b/docs/public/screenshots/menu-ios-vibrant.png new file mode 100644 index 0000000000..4f2ad5a787 Binary files /dev/null and b/docs/public/screenshots/menu-ios-vibrant.png differ diff --git a/docs/public/screenshots/menu-item.png b/docs/public/screenshots/menu-item.png index 09a7702557..5a2d0c96ef 100644 Binary files a/docs/public/screenshots/menu-item.png and b/docs/public/screenshots/menu-item.png differ diff --git a/docs/src/data/screenshots.ts b/docs/src/data/screenshots.ts index e18135fc49..19f98f69b5 100644 --- a/docs/src/data/screenshots.ts +++ b/docs/src/data/screenshots.ts @@ -108,7 +108,9 @@ export const screenshots = { 'List.Section': 'screenshots/list-section.png', Menu: { 'with icons': 'screenshots/menu-1.png', - 'without icons': 'screenshots/menu-2.png', + 'selected + supporting': 'screenshots/menu-2.png', + 'vibrant scheme': 'screenshots/menu-3.png', + 'bottom anchor': 'screenshots/menu-4.png', }, 'Menu.Item': 'screenshots/menu-item.png', Modal: 'screenshots/modal.gif', diff --git a/docs/src/data/themeColors.ts b/docs/src/data/themeColors.ts index b04ea8c7e7..39cb2c6142 100644 --- a/docs/src/data/themeColors.ts +++ b/docs/src/data/themeColors.ts @@ -294,18 +294,41 @@ export const themeColors = { }, }, Menu: { - '-': { - backgroundColor: 'theme.colors.elevation.level2', + standard: { + backgroundColor: 'theme.colors.surfaceContainerLow', + }, + vibrant: { + backgroundColor: 'theme.colors.tertiaryContainer', + }, + 'selected item': { + backgroundColor: 'theme.colors.tertiaryContainer', + textColor: 'theme.colors.onTertiaryContainer', }, }, 'Menu.Item': { default: { textColor: 'theme.colors.onSurface', iconColor: 'theme.colors.onSurfaceVariant', + supportingColor: 'theme.colors.onSurfaceVariant', + }, + selected: { + backgroundColor: 'theme.colors.tertiaryContainer', + textColor: 'theme.colors.onTertiaryContainer', + iconColor: 'theme.colors.onTertiaryContainer', }, disabled: { - textColor: 'theme.colors.onSurfaceDisabled', - iconColor: 'theme.colors.onSurfaceDisabled', + textColor: 'theme.colors.onSurface', + iconColor: 'theme.colors.onSurfaceVariant', + contentOpacity: 'theme.state.opacity.disabled (0.38)', + }, + vibrant: { + textColor: 'theme.colors.onTertiaryContainer', + iconColor: 'theme.colors.onTertiaryContainer', + }, + 'vibrant selected': { + backgroundColor: 'theme.colors.tertiary', + textColor: 'theme.colors.onTertiary', + iconColor: 'theme.colors.onTertiary', }, }, Modal: { diff --git a/example/src/Examples/MenuExample.tsx b/example/src/Examples/MenuExample.tsx index 2a55069090..86f4da5ee8 100644 --- a/example/src/Examples/MenuExample.tsx +++ b/example/src/Examples/MenuExample.tsx @@ -138,13 +138,57 @@ const MenuExample = () => { anchorPosition="bottom" anchor={ } > - {}} title="Item 1" /> - {}} title="Item 2" /> - {}} title="Item 3" /> + {}} + title="Copy" + trailingSupportingText="⌘C" + /> + {}} + title="Paste" + supportingText="Insert clipboard" + selected + /> + {}} + title="Share" + dense + /> + {}} title="Delete" disabled /> + + + + + + Vibrant color scheme + + } + > + {}} title="Featured" /> + {}} + title="Favorite" + selected + /> + {}} + title="Muted" + disabled + /> diff --git a/src/components/FAB/Menu.tsx b/src/components/FAB/Menu.tsx index 2aa808bb5e..caa5311b63 100644 --- a/src/components/FAB/Menu.tsx +++ b/src/components/FAB/Menu.tsx @@ -669,7 +669,7 @@ const Menu = ({ ); }; -Menu.displayName = 'Menu'; +Menu.displayName = 'FAB.Menu'; const styles = StyleSheet.create({ container: { diff --git a/src/components/Menu/Menu.tsx b/src/components/Menu/Menu.tsx index f83cec3a47..3706a4845e 100644 --- a/src/components/Menu/Menu.tsx +++ b/src/components/Menu/Menu.tsx @@ -1,5 +1,6 @@ import * as React from 'react'; import { + AccessibilityInfo, Dimensions, Keyboard, Platform, @@ -29,7 +30,10 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { scheduleOnRN } from 'react-native-worklets'; import useLatestCallback from 'use-latest-callback'; +import { MenuRootContext, type MenuItemRef } from './context'; import MenuItem from './MenuItem'; +import { MenuTokens, type MenuColorScheme } from './tokens'; +import { getMenuContainerBorderRadius, getMenuContainerColor } from './utils'; import { useLocale } from '../../core/locale'; import { useInternalTheme } from '../../core/theming'; import { useMotionDuration } from '../../theme/accessibility/ReduceMotionContext'; @@ -83,18 +87,27 @@ export type Props = { contentStyle?: StyleProp; style?: StyleProp; /** - * Elevation level of the menu's content. Shadow styles are calculated based on this value. Default `backgroundColor` is taken from the corresponding `theme.colors.elevation` property. By default equals `2`. + * Elevation level of the menu's content. Controls shadow only. + * Default fill is MD3 `surfaceContainerLow` (standard scheme) regardless of + * elevation — Paper's `elevation.levelN` tones are not the same as that role. + * By default equals `2`. * @supported Available in v5.x with theme version 3 */ elevation?: Elevation; /** * Mode of the menu's content. - * - `elevated` - Surface with a shadow and background color corresponding to set `elevation` value. - * - `flat` - Surface without a shadow, with the background color corresponding to set `elevation` value. + * - `elevated` - Surface with a shadow; fill from MD3 menu container role. + * - `flat` - Surface without a shadow; same fill role. * * @supported Available in v5.x with theme version 3 */ mode?: 'flat' | 'elevated'; + /** + * Color scheme for the menu surface and its items. + * - `standard` (default) — `surfaceContainerLow` fill + onSurface content + * - `vibrant` — M3 Expressive tertiary roles + */ + colorScheme?: MenuColorScheme; /** * @optional */ @@ -110,7 +123,7 @@ export type Props = { }; // Minimum padding between the edge of the screen and the menu -const SCREEN_INDENT = 8; +const SCREEN_INDENT = MenuTokens.sizes.screenIndent; // From https://material.io/design/motion/speed.html#duration const ANIMATION_DURATION = 250; // From the 'Standard easing' section of https://material.io/design/motion/speed.html#easing @@ -120,7 +133,7 @@ const WINDOW_LAYOUT = Dimensions.get('window'); const getKeyboardHeight = (fallback: number) => Keyboard.metrics?.()?.height ?? fallback; -const DEFAULT_ELEVATION: Elevation = 2; +const DEFAULT_ELEVATION: Elevation = MenuTokens.elevation.default; const DEFAULT_MODE = 'elevated'; const focusFirstDOMNode = ( @@ -139,6 +152,21 @@ const focusFirstDOMNode = ( } }; +const focusNativeNode = ( + el: React.ComponentRef | null | undefined +) => { + if (el && Platform.OS !== 'web') { + // Moves TalkBack / VoiceOver focus; the native node may not be + // accessible yet right after the animation, so defer one frame. + requestAnimationFrame(() => { + AccessibilityInfo.sendAccessibilityEvent(el, 'focus'); + // Input focus for a hardware keyboard. A no-op unless the app enables + // RN's `enableImperativeFocus` feature flag, and absent on older RN. + el.focus?.(); + }); + } +}; + const isCoordinate = (anchor: any): anchor is { x: number; y: number } => !React.isValidElement(anchor) && typeof anchor?.x === 'number' && @@ -147,6 +175,16 @@ const isCoordinate = (anchor: any): anchor is { x: number; y: number } => /** * Menus display a list of choices on temporary elevated surfaces. Their placement varies based on the element that opens them. * + * Follows [Material Design 3 menus](https://m3.material.io/components/menus/specs): container + * `corner.large`, fill `surfaceContainerLow` (elevation controls shadow only), item label + * `labelLarge`, selected items use `tertiaryContainer` / `onTertiaryContainer`. + * + * ## Accessibility + * When the menu opens, screen reader focus moves to its first enabled item, and it returns to + * the anchor when the menu closes. On Android, the Up and Down arrow keys move between the + * enabled items and skip disabled ones. Moving keyboard focus into the menu on open also needs + * React Native's `enableImperativeFocus` feature flag, which is off by default. + * * ## Usage * ```js * import * as React from 'react'; @@ -172,10 +210,24 @@ const isCoordinate = (anchor: any): anchor is { x: number; y: number } => * visible={visible} * onDismiss={closeMenu} * anchor={}> - * {}} title="Item 1" /> - * {}} title="Item 2" /> + * {}} + * title="Paste" + * supportingText="Insert clipboard" + * trailingSupportingText="⌘V" + * selected + * /> + * {}} title="Undo" /> * - * {}} title="Item 3" /> + * {}} title="Share" dense /> + * + * {}} + * colorScheme="vibrant" + * anchor={}> + * {}} title="Featured" selected /> * * * @@ -204,6 +256,7 @@ const Menu = ({ style, elevation = DEFAULT_ELEVATION, mode = DEFAULT_MODE, + colorScheme = 'standard', children, theme: themeOverrides, keyboardShouldPersistTaps, @@ -212,7 +265,6 @@ const Menu = ({ const { direction } = useLocale(); const insets = useSafeAreaInsets(); - const [rendered, setRendered] = React.useState(visible); const [left, setLeft] = React.useState(0); const [top, setTop] = React.useState(0); @@ -235,6 +287,11 @@ const Menu = ({ const anchorRef = React.useRef | null>(null); const menuRef = React.useRef | null>(null); const isShownRef = React.useRef(false); + const [items, setItems] = React.useState([]); + const registerItem = React.useCallback((item: MenuItemRef) => { + setItems((prev) => [...prev, item]); + return () => setItems((prev) => prev.filter((it) => it !== item)); + }, []); const keyboardDidShow = React.useCallback((e: RNKeyboardEvent) => { const keyboardHeight = e.endCoordinates.height; @@ -316,6 +373,7 @@ const Menu = ({ isShownRef.current = true; focusFirstDOMNode(menuRef.current); + focusNativeNode(items[0]?.current); }); const handleHideAnimationFinished = useLatestCallback((finished: boolean) => { @@ -329,6 +387,7 @@ const Menu = ({ setRendered(false); isShownRef.current = false; focusFirstDOMNode(anchorRef.current); + focusNativeNode(anchorRef.current); }); const getDuration = useMotionDuration(); @@ -665,6 +724,13 @@ const Menu = ({ const pointerEvents = visible ? 'box-none' : 'none'; + const rootContext = React.useMemo( + () => ({ colorScheme, registerItem, items }), + [colorScheme, registerItem, items] + ); + + const surfaceBackground = getMenuContainerColor({ theme, colorScheme }); + return ( { @@ -699,7 +765,8 @@ const Menu = ({ > - {(scrollableMenuHeight && ( - - {children} - - )) || {children}} + + {(scrollableMenuHeight && ( + + {children} + + )) || {children}} + @@ -744,7 +813,9 @@ const styles = StyleSheet.create({ opacity: 0, }, menuContent: { - paddingVertical: 8, + paddingHorizontal: MenuTokens.sizes.containerPaddingHorizontal, + paddingVertical: MenuTokens.sizes.containerPaddingVertical, + marginVertical: MenuTokens.sizes.containerMarginVertical, }, fill: { height: '100%', diff --git a/src/components/Menu/MenuItem.tsx b/src/components/Menu/MenuItem.tsx index b3707e20db..1519837240 100644 --- a/src/components/Menu/MenuItem.tsx +++ b/src/components/Menu/MenuItem.tsx @@ -1,15 +1,22 @@ import * as React from 'react'; -import { StyleSheet, View } from 'react-native'; -import type { - GestureResponderEvent, - PressableAndroidRippleConfig, - StyleProp, - TextStyle, - ViewStyle, +import { + findNodeHandle, + Platform, + StyleSheet, + View, + type Role, + type GestureResponderEvent, + type PressableAndroidRippleConfig, + type StyleProp, + type TextStyle, + type ViewStyle, } from 'react-native'; +import { useMenuRoot, type MenuItemRef } from './context'; +import { MenuTokens, type MenuColorScheme } from './tokens'; import { getContentMaxWidth, + getMenuItemBorderRadius, getMenuItemColor, MAX_WIDTH, MIN_WIDTH, @@ -27,6 +34,14 @@ export type Props = { * Title text for the `MenuItem`. */ title: React.ReactNode; + /** + * Optional supporting text rendered under the title (`bodySmall`). + */ + supportingText?: React.ReactNode; + /** + * Optional trailing supporting text (`labelLarge`), e.g. a keyboard shortcut. + */ + trailingSupportingText?: React.ReactNode; /** * @renamed Renamed from 'icon' to 'leadingIcon' in v5.x * @@ -39,6 +54,22 @@ export type Props = { * Trailing icon to display for the `MenuItem`. */ trailingIcon?: IconSource; + /** + * Whether the item is selected / active. Applies MD3 selected colors + * (`tertiaryContainer` / `onTertiaryContainer` in the standard scheme) + * and `corner.medium` rounding. + * + * On web this also marks the item as `menuitemradio`, so assistive tech + * announces it as one of a set. Pass `selected={false}` on the other items + * in the group so they share the role. + */ + selected?: boolean; + /** + * Color scheme for the item. Inherited from parent `Menu` when omitted. + * - `standard` (default) + * - `vibrant` — M3 Expressive tertiary roles + */ + colorScheme?: MenuColorScheme; /** * Whether the 'item' is disabled. A disabled 'item' is greyed out and `onPress` is not called on touch. */ @@ -59,7 +90,8 @@ export type Props = { */ onPress?: (e: GestureResponderEvent) => void; /** - * Specifies the largest possible scale a title font can reach. + * Specifies the largest possible scale the title font can reach. Also applies to + * the supporting and trailing supporting text. */ titleMaxFontSizeMultiplier?: number; /** @@ -72,13 +104,21 @@ export type Props = { */ containerStyle?: StyleProp; /** - * Style that is passed to the content container, which wraps the title text. + * Style that is passed to the content container. */ contentStyle?: StyleProp; /** * Style that is passed to the Title element. */ titleStyle?: StyleProp; + /** + * Style that is passed to the supporting text element. + */ + supportingTextStyle?: StyleProp; + /** + * Style that is passed to the trailing supporting text element. + */ + trailingSupportingTextStyle?: StyleProp; /** * @optional */ @@ -98,10 +138,14 @@ export type Props = { /** * Indicates whether the element is checked. Accepts `true`, `false`, * or `'mixed'` for an indeterminate state. + * + * On web this marks the item as `menuitemcheckbox`, for options that toggle + * independently rather than forming a single-choice group. */ 'aria-checked'?: boolean | 'mixed'; /** - * Indicates whether the element is selected. + * Indicates whether the element is selected. Prefer `selected`, which maps to + * `aria-checked` — the state assistive tech reads on a menu item. */ 'aria-selected'?: boolean; /** @@ -114,9 +158,51 @@ export type Props = { 'aria-expanded'?: boolean; }; +// Android's own directional search skips disabled items and can jump out of +// the menu, so link each enabled item to its neighbours for Up / Down. The +// ends are left to the default search; Tab stays native and is not trapped. +const getNextFocusProps = ( + order: MenuItemRef[] | undefined, + self: MenuItemRef +) => { + const index = order?.indexOf(self) ?? -1; + + if (Platform.OS !== 'android' || !order || index < 0) { + return null; + } + + const tagAt = (i: number) => + (order[i] && findNodeHandle(order[i].current)) || undefined; + + return { nextFocusDown: tagAt(index + 1), nextFocusUp: tagAt(index - 1) }; +}; + +// Native keeps plain `menuitem`: Android drops the role description for a +// value it cannot map, and iOS ignores all of them anyway. +const getRole = ( + ariaChecked: Props['aria-checked'], + selected: Props['selected'] +): Role => { + if (Platform.OS !== 'web') { + return 'menuitem'; + } + if (ariaChecked !== undefined) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- valid ARIA role missing from RN's union + return 'menuitemcheckbox' as Role; + } + if (selected !== undefined) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- valid ARIA role missing from RN's union + return 'menuitemradio' as Role; + } + return 'menuitem'; +}; + /** * A component to show a single list item inside a Menu. * + * Supports MD3 selection (`selected`), supporting text, trailing supporting text, + * and dense layout. + * * ## Usage * ```js * import * as React from 'react'; @@ -129,7 +215,15 @@ export type Props = { * {}} title="Undo" /> * {}} title="Cut" disabled /> * {}} title="Copy" disabled /> - * {}} title="Paste" /> + * {}} + * title="Paste" + * supportingText="Insert clipboard" + * trailingSupportingText="⌘V" + * selected + * /> + * * * ); * @@ -141,6 +235,10 @@ const MenuItem = ({ trailingIcon, dense, title, + supportingText, + trailingSupportingText, + selected: selectedProp, + colorScheme: colorSchemeProp, disabled, background, onPress, @@ -148,6 +246,8 @@ const MenuItem = ({ containerStyle, contentStyle, titleStyle, + supportingTextStyle, + trailingSupportingTextStyle, testID, 'aria-label': ariaLabel, 'aria-checked': ariaChecked, @@ -159,37 +259,95 @@ const MenuItem = ({ hitSlop, }: Props) => { const theme = useInternalTheme(themeOverrides); - const { titleColor, iconColor, contentOpacity } = getMenuItemColor({ + const root = useMenuRoot(); + const selected = selectedProp ?? false; + + const itemRef = React.useRef>(null); + const nextFocusProps = getNextFocusProps(root?.items, itemRef); + const registerItem = root?.registerItem; + // Only enabled items can take focus, so only they register. + React.useEffect( + () => (disabled ? undefined : registerItem?.(itemRef)), + [disabled, registerItem] + ); + + const role = getRole(ariaChecked, selectedProp); + + const colorScheme = colorSchemeProp ?? root?.colorScheme ?? 'standard'; + + const { + titleColor, + iconColor, + supportingColor, + containerColor, + contentOpacity, + } = getMenuItemColor({ theme, disabled, + selected, + colorScheme, }); - const containerPadding = 12; - const iconWidth = 24; + const { + itemPaddingHorizontal, + iconSize, + iconLabelGap, + noLeadingIconStart, + itemHeight, + denseItemHeight, + minWidth, + maxWidth, + } = MenuTokens.sizes; - const minWidth = MIN_WIDTH - 12; + const hasSupportingText = + supportingText != null && typeof supportingText !== 'boolean'; + const hasTrailingSupportingText = + trailingSupportingText != null && + typeof trailingSupportingText !== 'boolean'; - const maxWidth = getContentMaxWidth({ - iconWidth, + const contentMaxWidth = getContentMaxWidth({ + iconWidth: iconSize, leadingIcon, trailingIcon, + hasTrailingSupportingText, }); const titleTextStyle = { color: titleColor, - ...theme.fonts.bodyLarge, + ...theme.fonts[MenuTokens.typography.label], + }; + + const supportingTextStyleResolved = { + color: supportingColor, + ...theme.fonts[MenuTokens.typography.supporting], + }; + + const trailingSupportingTextStyleResolved = { + color: supportingColor, + ...theme.fonts[MenuTokens.typography.trailingSupporting], }; return ( {leadingIcon ? ( - - + + ) : null} {title} + {hasSupportingText ? ( + + {supportingText} + + ) : null} + {hasTrailingSupportingText ? ( + + {trailingSupportingText} + + ) : null} {trailingIcon ? ( - - + + ) : null} @@ -246,23 +441,29 @@ const styles = StyleSheet.create({ container: { minWidth: MIN_WIDTH, maxWidth: MAX_WIDTH, - height: 48, justifyContent: 'center', - }, - md3DenseContainer: { - height: 32, + overflow: 'hidden', }, row: { flexDirection: 'row', + alignItems: 'center', + maxWidth: MAX_WIDTH - MenuTokens.sizes.itemPaddingHorizontal * 2, + }, + leadingIcon: { + flexShrink: 0, }, content: { + flexShrink: 1, + flexGrow: 1, justifyContent: 'center', }, - md3LeadingIcon: { + trailingSupporting: { marginLeft: 12, + flexShrink: 0, }, - md3WithoutLeadingIcon: { - marginLeft: 4, + trailingIcon: { + marginLeft: 12, + flexShrink: 0, }, }); diff --git a/src/components/Menu/context.tsx b/src/components/Menu/context.tsx new file mode 100644 index 0000000000..86eb152fd1 --- /dev/null +++ b/src/components/Menu/context.tsx @@ -0,0 +1,32 @@ +import * as React from 'react'; +import type { View } from 'react-native'; + +import type { MenuColorScheme } from './tokens'; + +/** Host node of an enabled `MenuItem`. */ +export type MenuItemRef = React.RefObject | null>; + +/** + * Root menu state: color scheme, and the enabled items for focus handling. + * Provided by `Menu`; consumed by items. + */ +type MenuRootContextValue = { + colorScheme: MenuColorScheme; + /** + * Enabled items in registration order. The menu focuses the first one when + * it opens, and items link native Up / Down focus to their neighbours. + */ + items: MenuItemRef[]; + /** Registers an enabled item. Returns an unregister function. */ + registerItem: (item: MenuItemRef) => () => void; +}; + +export const MenuRootContext = React.createContext( + null +); + +export function useMenuRoot() { + return React.useContext(MenuRootContext); +} diff --git a/src/components/Menu/tokens.ts b/src/components/Menu/tokens.ts new file mode 100644 index 0000000000..01dd067942 --- /dev/null +++ b/src/components/Menu/tokens.ts @@ -0,0 +1,93 @@ +import type { ColorRole, Elevation, TypescaleKey } from '../../theme/types'; +import type { ShapeToken } from '../../theme/utils/shape'; + +/** + * MD3 Menu / Menu.Item dimensions, shapes, color roles and typescale. + * @see https://m3.material.io/components/menus/specs + */ +const sizes = { + /** Min width of a menu item (and thus the menu). */ + minWidth: 112, + /** Max width of a menu item (and thus the menu). */ + maxWidth: 280, + /** Standard item height. */ + itemHeight: 48, + /** Dense item height. */ + denseItemHeight: 32, + /** Horizontal padding inside an item. */ + itemPaddingHorizontal: 12, + /** Leading icon size. */ + iconSize: 20, + /** Gap between leading icon and label. */ + iconLabelGap: 8, + /** Extra start inset when there is no leading icon. */ + noLeadingIconStart: 4, + /** Vertical margin of the menu surface. */ + containerMarginVertical: 2, + /** Vertical padding of the menu surface. */ + containerPaddingVertical: 2, + /** Horizontal padding of the menu surface. */ + containerPaddingHorizontal: 4, + /** Min distance from screen edge. */ + screenIndent: 8, +} as const; + +const shapes = { + /** Menu surface corner. Spec: corner.large (16dp). */ + container: 'large', + /** Item corners at rest. Spec: corner.extra-small. */ + item: 'extraSmall', + /** Selected item corners. Spec: corner.medium. */ + itemSelected: 'medium', +} as const satisfies Record; + +const typography = { + label: 'labelLarge', + supporting: 'bodySmall', + trailingSupporting: 'labelLarge', +} as const satisfies Record; + +/** + * Standard (baseline) color scheme roles. + * Menu surface fill is the MD3 role `surfaceContainerLow` (not elevation.level2 — + * Paper's elevation.level2 maps to surfaceContainer tones, which is a different color). + * The `elevation` prop still drives shadow only. + */ +const standardColors = { + /** MD3 menu container fill. */ + container: 'surfaceContainerLow', + label: 'onSurface', + icon: 'onSurfaceVariant', + supporting: 'onSurfaceVariant', + selectedContainer: 'tertiaryContainer', + selectedContent: 'onTertiaryContainer', +} as const satisfies Record; + +/** + * M3 Expressive vibrant menu roles. + * @see https://m3.material.io/components/menus/specs + */ +const vibrantColors = { + label: 'onTertiaryContainer', + icon: 'onTertiaryContainer', + supporting: 'onTertiaryContainer', + /** Vibrant menu surface uses tertiaryContainer instead of elevation surface. */ + container: 'tertiaryContainer', + selectedContainer: 'tertiary', + selectedContent: 'onTertiary', +} as const satisfies Record; + +const elevation = { + default: 2, +} as const satisfies Record; + +export const MenuTokens = { + sizes, + shapes, + typography, + standardColors, + vibrantColors, + elevation, +}; + +export type MenuColorScheme = 'standard' | 'vibrant'; diff --git a/src/components/Menu/utils.ts b/src/components/Menu/utils.ts index 13cadc9917..c88417ff52 100644 --- a/src/components/Menu/utils.ts +++ b/src/components/Menu/utils.ts @@ -1,64 +1,134 @@ -import type { ColorValue } from 'react-native'; +import type { ColorValue, ViewStyle } from 'react-native'; +import { MenuTokens, type MenuColorScheme } from './tokens'; import { tokens } from '../../theme/tokens'; import type { InternalTheme } from '../../theme/types'; +import { resolveCornerRadius } from '../../theme/utils/shape'; import type { IconSource } from '../Icon'; const stateOpacity = tokens.md.sys.state.opacity; -export const MIN_WIDTH = 112; -export const MAX_WIDTH = 280; +export const MIN_WIDTH = MenuTokens.sizes.minWidth; +export const MAX_WIDTH = MenuTokens.sizes.maxWidth; type ContentProps = { iconWidth: number; leadingIcon?: IconSource; trailingIcon?: IconSource; + hasTrailingSupportingText?: boolean; }; type ColorProps = { theme: InternalTheme; disabled?: boolean; + selected?: boolean; + colorScheme?: MenuColorScheme; }; -const getTitleColor = ({ theme }: ColorProps) => { - return theme.colors.onSurface; -}; - -const getIconColor = ({ theme }: ColorProps) => { - return theme.colors.onSurfaceVariant; -}; +const resolveRoles = (colorScheme: MenuColorScheme = 'standard') => + colorScheme === 'vibrant' + ? MenuTokens.vibrantColors + : MenuTokens.standardColors; export const getMenuItemColor = ({ theme, disabled, + selected, + colorScheme = 'standard', }: ColorProps): { titleColor: ColorValue; iconColor: ColorValue; + supportingColor: ColorValue; + containerColor: ColorValue | undefined; contentOpacity: number; } => { + const roles = resolveRoles(colorScheme); const contentOpacity = disabled ? stateOpacity.disabled : stateOpacity.enabled; + const useSelected = Boolean(selected) && !disabled; + + const titleColor: ColorValue = useSelected + ? theme.colors[roles.selectedContent] + : theme.colors[roles.label]; + + const iconColor: ColorValue = useSelected + ? theme.colors[roles.selectedContent] + : theme.colors[roles.icon]; + + const supportingColor: ColorValue = useSelected + ? theme.colors[roles.selectedContent] + : theme.colors[roles.supporting]; + + const containerColor: ColorValue | undefined = useSelected + ? theme.colors[roles.selectedContainer] + : undefined; + return { - titleColor: getTitleColor({ theme, disabled }), - iconColor: getIconColor({ theme, disabled }), + titleColor, + iconColor, + supportingColor, + containerColor, contentOpacity, }; }; +/** + * Resolve the menu surface background. + * Standard: MD3 `surfaceContainerLow` (not elevation.levelN — those map to + * different surfaceContainer* tones in this theme; elevation drives shadow only). + * Vibrant: tertiaryContainer. + */ +export const getMenuContainerColor = ({ + theme, + colorScheme = 'standard', +}: { + theme: InternalTheme; + colorScheme?: MenuColorScheme; +}): ColorValue => { + if (colorScheme === 'vibrant') { + return theme.colors[MenuTokens.vibrantColors.container]; + } + return theme.colors[MenuTokens.standardColors.container]; +}; + export const getContentMaxWidth = ({ iconWidth, leadingIcon, trailingIcon, + hasTrailingSupportingText, }: ContentProps) => { - if (leadingIcon && trailingIcon) { - return MAX_WIDTH - (2 * iconWidth + 24); + let reserved = 12; + if (leadingIcon) { + reserved += iconWidth + MenuTokens.sizes.iconLabelGap; } - - if (leadingIcon || trailingIcon) { - return MAX_WIDTH - (iconWidth + 24); + if (trailingIcon) { + reserved += iconWidth + 12; } - - return MAX_WIDTH - 12; + if (hasTrailingSupportingText) { + // Trailing supporting text shares trailing space; reserve a modest slot. + reserved += 48; + } + return MAX_WIDTH - reserved; }; + +/** + * Per-item corner radius. Spec: corner.extra-small at rest, corner.medium when + * selected. + */ +export const getMenuItemBorderRadius = ({ + theme, + selected, +}: { + theme: InternalTheme; + selected?: boolean; +}): ViewStyle => ({ + borderRadius: resolveCornerRadius( + theme, + selected ? MenuTokens.shapes.itemSelected : MenuTokens.shapes.item + ), +}); + +export const getMenuContainerBorderRadius = (theme: InternalTheme): number => + resolveCornerRadius(theme, MenuTokens.shapes.container); diff --git a/src/components/__tests__/Menu.test.tsx b/src/components/__tests__/Menu.test.tsx index 7fced51b87..30abfaa63e 100644 --- a/src/components/__tests__/Menu.test.tsx +++ b/src/components/__tests__/Menu.test.tsx @@ -1,5 +1,12 @@ import type { ComponentRef } from 'react'; -import { Dimensions, Keyboard, Platform, StyleSheet, View } from 'react-native'; +import { + AccessibilityInfo, + Dimensions, + Keyboard, + Platform, + StyleSheet, + View, +} from 'react-native'; import { afterEach, @@ -17,6 +24,7 @@ import { render } from '../../test-utils'; import { LightTheme } from '../../theme/schemes'; import type { Elevation } from '../../theme/types'; import Button from '../Button/Button'; +import Divider from '../Divider'; import Menu from '../Menu/Menu'; import Portal from '../Portal/Portal'; @@ -129,6 +137,119 @@ describe('web focus', () => { }); }); +describe('screen reader focus', () => { + const PAST_ANIMATION_MS = 300; + // The focus call is deferred one frame past the animation. + const PAST_FRAME_MS = 32; + let sendEvent: jest.SpiedFunction< + typeof AccessibilityInfo.sendAccessibilityEvent + >; + + const originalMeasureInWindow = Object.getOwnPropertyDescriptor( + View.prototype, + 'measureInWindow' + ); + + beforeEach(() => { + // Measuring never resolves in the test renderer, which blocks showing. + const measureInWindow: ComponentRef['measureInWindow'] = ( + fn + ) => fn(100, 100, 80, 32); + Object.defineProperty(View.prototype, 'measureInWindow', { + configurable: true, + value: measureInWindow, + }); + sendEvent = jest + .spyOn(AccessibilityInfo, 'sendAccessibilityEvent') + .mockImplementation(() => undefined); + }); + + afterEach(() => { + if (originalMeasureInWindow) { + Object.defineProperty( + View.prototype, + 'measureInWindow', + originalMeasureInWindow + ); + } else { + Reflect.deleteProperty(View.prototype, 'measureInWindow'); + } + sendEvent.mockRestore(); + }); + + const makeMenu = (visible: boolean, disabled: string[] = []) => ( + + Open menu}> + {['undo', 'redo', 'copy'].map((id) => ( + + ))} + + + ); + + const finishAnimation = async () => { + await act(() => jest.advanceTimersByTime(PAST_ANIMATION_MS)); + await act(() => jest.advanceTimersByTime(PAST_FRAME_MS)); + }; + + // The focus event receives the host ref, which in the test renderer is the + // mocked `View` instance. There is no user-visible way to identify it, so + // read its testID and compare ids to keep failure output small. + const focusedTestIDs = () => + sendEvent.mock.calls.map(([node]) => { + if (typeof node !== 'object' || node === null || !('props' in node)) { + return undefined; + } + const { props } = node; + return typeof props === 'object' && props !== null && 'testID' in props + ? props.testID + : undefined; + }); + + it('focuses the first enabled item after the show animation, skipping a disabled one', async () => { + const { rerender } = await render(makeMenu(false, ['undo'])); + await rerender(makeMenu(true, ['undo'])); + await finishAnimation(); + + expect(focusedTestIDs()).toEqual(['redo']); + expect(sendEvent.mock.calls[0][1]).toBe('focus'); + }); + + it('returns focus to the anchor after the hide animation', async () => { + const { rerender } = await render(makeMenu(true)); + await finishAnimation(); + sendEvent.mockClear(); + + await rerender(makeMenu(false)); + await finishAnimation(); + + expect(sendEvent).toHaveBeenCalledTimes(1); + expect(focusedTestIDs()).not.toContain('undo'); + }); + + it('stops targeting an item once it becomes disabled', async () => { + const { rerender } = await render(makeMenu(false)); + await rerender(makeMenu(true)); + await rerender(makeMenu(true, ['undo'])); + await finishAnimation(); + + expect(focusedTestIDs()).toEqual(['redo']); + }); + + it('sends no focus event to an item when every item is disabled', async () => { + const { rerender } = await render(makeMenu(false)); + await rerender(makeMenu(true, ['undo', 'redo', 'copy'])); + await finishAnimation(); + + expect(sendEvent).not.toHaveBeenCalled(); + }); +}); + it('renders visible menu', async () => { const tree = ( await render( @@ -172,7 +293,8 @@ const ViewPrototype: ComponentRef = View.prototype; const elevations: Elevation[] = [0, 1, 2, 3, 4, 5]; elevations.forEach((elevation) => - it(`renders menu with background color based on elevation value = ${elevation}`, async () => { + it(`uses surfaceContainerLow fill independent of elevation value = ${elevation}`, async () => { + const theme = LightTheme; const testID = 'menu-with-elevation'; await render( @@ -191,12 +313,122 @@ elevations.forEach((elevation) => ); + // C1: MD3 menu fill is surfaceContainerLow, not elevation.levelN + // (level2 is surfaceContainer tones in this theme — a different color). expect(screen.getByTestId(testID)).toHaveStyle({ - backgroundColor: LightTheme.colors.elevation[`level${elevation}`], + backgroundColor: theme.colors.surfaceContainerLow, }); + expect(theme.colors.surfaceContainerLow).not.toBe( + theme.colors.elevation.level2 + ); }) ); +it('uses corner.large for the menu surface', async () => { + const theme = LightTheme; + + await render( + + Open menu} + > + + + + ); + + expect(screen.getByTestId('menu-surface')).toHaveStyle({ + borderRadius: theme.shapes.corner.large, + }); +}); + +it('uses tertiaryContainer for vibrant color scheme', async () => { + const theme = LightTheme; + + await render( + + Open menu} + > + + + + ); + + expect(screen.getByTestId('menu-surface')).toHaveStyle({ + backgroundColor: theme.colors.tertiaryContainer, + }); +}); + +it('inherits the vibrant color scheme for items rendered inside a wrapper', async () => { + const theme = LightTheme; + + await render( + + Open menu} + > + + + + + + ); + + expect(screen.getByText('Undo')).toHaveStyle({ + color: theme.colors.onTertiaryContainer, + }); +}); + +it('rounds items at rest to corner.extra-small', async () => { + await render( + + Open menu} + > + + + + + ); + + const radius = LightTheme.shapes.corner.extraSmall; + + expect(screen.getByTestId('first-item')).toHaveStyle({ + borderRadius: radius, + }); + expect(screen.getByTestId('last-item')).toHaveStyle({ borderRadius: radius }); +}); + +it('still renders Divider between items', async () => { + await render( + + Open menu} + > + + + + + + ); + expect(screen.getByTestId('menu-divider')).toBeOnTheScreen(); +}); + it('uses the default anchorPosition of top', async () => { const testID = 'top-positioned-menu'; const dimensionsSpy = jest.spyOn(Dimensions, 'get').mockReturnValue({ @@ -439,6 +671,7 @@ it('does not crash when Keyboard.metrics is unavailable (react-native-web)', asy .mockImplementation((fn) => fn(100, 100, 80, 32)); function makeMenu(visible: boolean) { + // PaperProvider reduceMotion="on" is the real product path for reduce-motion. return ( { + const row = screen.getByText(title).parent?.parent; + if (!row) { + throw new Error(`No content row found for "${title}"`); + } + return row; +}; + describe('Menu Item', () => { it('renders menu item', async () => { const tree = ( @@ -64,6 +77,186 @@ describe('Menu Item', () => { expect.objectContaining({ checked: true }) ); }); + + it('uses labelLarge for the title', async () => { + await render(); + + expect(screen.getByText('Paste')).toHaveStyle(LightTheme.fonts.labelLarge); + }); + + it('renders supporting and trailing supporting text', async () => { + const theme = LightTheme; + await render( + {}} + /> + ); + + expect(screen.getByText('Send a link')).toBeOnTheScreen(); + expect(screen.getByText('⌘S')).toBeOnTheScreen(); + // two-line anatomy must not use fixed 48 height (would clip supporting) + expect(screen.getByTestId('menu-item')).toHaveStyle({ + minHeight: 48, + paddingVertical: 8, + }); + // B2: supporting uses bodySmall + onSurfaceVariant + expect(screen.getByText('Send a link')).toHaveStyle({ + ...theme.fonts.bodySmall, + color: theme.colors.onSurfaceVariant, + }); + // B3: trailing supporting uses labelLarge + expect(screen.getByText('⌘S')).toHaveStyle({ + ...theme.fonts.labelLarge, + color: theme.colors.onSurfaceVariant, + }); + // explicit aria-label stays on the menuitem + expect( + screen.getByRole('menuitem', { + name: 'Share, send a link, keyboard shortcut Command S', + }) + ).toBeOnTheScreen(); + }); + + it('renders numeric supporting text values like 0', async () => { + await render( + + ); + + // One `0` for the supporting text, one for the trailing supporting text. + expect(screen.getAllByText('0')).toHaveLength(2); + }); + + it('ignores boolean placeholders for supporting text', async () => { + await render( + + ); + + expect(screen.queryByText('false')).toBeNull(); + }); + + it('grows for a trailing-only row so large font scales are not clipped', async () => { + await render( + + ); + + expect(screen.getByTestId('menu-item')).toHaveStyle({ + minHeight: MenuTokens.sizes.itemHeight, + paddingVertical: 8, + }); + expect(screen.getByTestId('menu-item')).not.toHaveStyle({ + height: MenuTokens.sizes.itemHeight, + }); + }); + + it('applies titleMaxFontSizeMultiplier to the supporting texts too', async () => { + await render( + + ); + + expect(screen.getByText('Share')).toHaveProp('maxFontSizeMultiplier', 2); + expect(screen.getByText('Send a link')).toHaveProp( + 'maxFontSizeMultiplier', + 2 + ); + expect(screen.getByText('⌘S')).toHaveProp('maxFontSizeMultiplier', 2); + }); + + it('defaults supporting text scaling to the title cap', async () => { + await render( + + ); + + expect(screen.getByText('Send a link')).toHaveProp( + 'maxFontSizeMultiplier', + 1.5 + ); + expect(screen.getByText('⌘S')).toHaveProp('maxFontSizeMultiplier', 1.5); + }); + + it('keeps fixed height for single-line items', async () => { + await render(); + expect(screen.getByTestId('menu-item')).toHaveStyle({ height: 48 }); + }); + + it('uses dense item height of 32 when dense', async () => { + await render(); + expect(screen.getByTestId('menu-item')).toHaveStyle({ + height: MenuTokens.sizes.denseItemHeight, + minHeight: MenuTokens.sizes.denseItemHeight, + }); + expect(MenuTokens.sizes.denseItemHeight).toBe(32); + }); + + it('announces selection as checked state and applies selected colors', async () => { + const theme = LightTheme; + await render( + {}} /> + ); + + expect(screen.getByRole('menuitem')).toHaveProp( + 'accessibilityState', + expect.objectContaining({ checked: true }) + ); + expect(screen.getByTestId('menu-item')).toHaveStyle({ + backgroundColor: theme.colors.tertiaryContainer, + }); + expect(screen.getByText('Paste')).toHaveStyle({ + color: theme.colors.onTertiaryContainer, + }); + }); + + it('disabled wins over selected for content opacity', async () => { + await render( + {}} + /> + ); + + expect(screen.getByRole('menuitem')).toHaveProp( + 'accessibilityState', + expect.objectContaining({ disabled: true }) + ); + // selected container is suppressed when disabled + expect(screen.getByTestId('menu-item')).not.toHaveStyle({ + backgroundColor: LightTheme.colors.tertiaryContainer, + }); + expect(contentRow('Paste')).toHaveStyle({ + opacity: stateOpacity.disabled, + }); + }); + + it('applies corner.medium on all sides when selected', async () => { + const theme = LightTheme; + const radius = resolveCornerRadius(theme, MenuTokens.shapes.itemSelected); + + await render(); + + expect(screen.getByTestId('menu-item')).toHaveStyle({ + borderRadius: radius, + }); + }); }); describe('getMenuItemColor - title color', () => { @@ -88,6 +281,36 @@ describe('getMenuItemColor - title color', () => { titleColor: LightTheme.colors.onSurface, }); }); + + it('returns selected tertiary roles when selected', () => { + const theme = LightTheme; + expect( + getMenuItemColor({ + theme, + selected: true, + }) + ).toMatchObject({ + titleColor: theme.colors.onTertiaryContainer, + iconColor: theme.colors.onTertiaryContainer, + containerColor: theme.colors.tertiaryContainer, + contentOpacity: stateOpacity.enabled, + }); + }); + + it('ignores selected colors when disabled', () => { + const theme = LightTheme; + expect( + getMenuItemColor({ + theme, + selected: true, + disabled: true, + }) + ).toMatchObject({ + titleColor: theme.colors.onSurface, + containerColor: undefined, + contentOpacity: stateOpacity.disabled, + }); + }); }); describe('getMenuItemColor - icon color', () => { @@ -113,3 +336,49 @@ describe('getMenuItemColor - icon color', () => { }); }); }); + +describe('Menu shape tokens', () => { + it('uses corner.extra-small at rest and corner.medium when selected', () => { + const theme = LightTheme; + expect(getMenuItemBorderRadius({ theme })).toEqual({ + borderRadius: theme.shapes.corner.extraSmall, + }); + expect(getMenuItemBorderRadius({ theme, selected: true })).toEqual({ + borderRadius: theme.shapes.corner.medium, + }); + expect(theme.shapes.corner.extraSmall).toBe(4); + expect(theme.shapes.corner.medium).toBe(12); + }); +}); + +describe('Menu.Item ARIA role', () => { + const setPlatform = (os: 'web' | 'ios') => { + Object.defineProperty(Platform, 'OS', { + get: () => os, + configurable: true, + }); + }; + + afterEach(() => setPlatform('ios')); + + it.each([ + { os: 'ios', props: { selected: true }, role: 'menuitem' }, + { os: 'web', props: { selected: true }, role: 'menuitemradio' }, + { os: 'web', props: { 'aria-checked': 'mixed' }, role: 'menuitemcheckbox' }, + { os: 'web', props: {}, role: 'menuitem' }, + ] as const)( + 'uses role $role on $os with $props', + async ({ os, props, role }) => { + setPlatform(os); + await render( + {}} + {...props} + /> + ); + expect(screen.getByTestId('menu-item')).toHaveProp('role', role); + } + ); +}); diff --git a/src/components/__tests__/__snapshots__/Menu.test.tsx.snap b/src/components/__tests__/__snapshots__/Menu.test.tsx.snap index f08083bb2c..4e3ed6503e 100644 --- a/src/components/__tests__/__snapshots__/Menu.test.tsx.snap +++ b/src/components/__tests__/__snapshots__/Menu.test.tsx.snap @@ -539,7 +539,7 @@ exports[`renders visible menu 1`] = ` }, {}, { - "backgroundColor": "rgba(243, 237, 247, 1)", + "backgroundColor": "rgba(247, 242, 250, 1)", }, { "borderBottomEndRadius": undefined, @@ -549,7 +549,7 @@ exports[`renders visible menu 1`] = ` "borderCurve": "continuous", "borderEndEndRadius": undefined, "borderEndStartRadius": undefined, - "borderRadius": 4, + "borderRadius": 16, "borderStartEndRadius": undefined, "borderStartStartRadius": undefined, "borderTopEndRadius": undefined, @@ -586,7 +586,7 @@ exports[`renders visible menu 1`] = ` {}, {}, { - "backgroundColor": "rgba(243, 237, 247, 1)", + "backgroundColor": "rgba(247, 242, 250, 1)", }, { "borderBottomEndRadius": undefined, @@ -596,7 +596,7 @@ exports[`renders visible menu 1`] = ` "borderCurve": "continuous", "borderEndEndRadius": undefined, "borderEndStartRadius": undefined, - "borderRadius": 4, + "borderRadius": 16, "borderStartEndRadius": undefined, "borderStartStartRadius": undefined, "borderTopEndRadius": undefined, @@ -621,7 +621,9 @@ exports[`renders visible menu 1`] = ` style={ [ { - "paddingVertical": 8, + "marginVertical": 2, + "paddingHorizontal": 4, + "paddingVertical": 2, }, false, undefined, @@ -664,15 +666,22 @@ exports[`renders visible menu 1`] = ` false, [ { - "height": 48, "justifyContent": "center", "maxWidth": 280, "minWidth": 112, + "overflow": "hidden", }, { + "height": 48, + "maxWidth": 280, + "minHeight": 48, + "minWidth": 112, "paddingHorizontal": 12, }, - undefined, + { + "borderRadius": 4, + }, + null, undefined, ], ] @@ -682,7 +691,9 @@ exports[`renders visible menu 1`] = ` style={ [ { + "alignItems": "center", "flexDirection": "row", + "maxWidth": 256, }, { "opacity": 1, @@ -692,15 +703,16 @@ exports[`renders visible menu 1`] = ` } >