From b8afb935f4eafbe64e83512ec5a97bb7b38a6ecb Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 12 Mar 2024 11:23:01 -0500 Subject: Unwrap Menu.Trigger on web (#3182) --- src/components/Menu/types.ts | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'src/components/Menu/types.ts') diff --git a/src/components/Menu/types.ts b/src/components/Menu/types.ts index 2f52e6390..7d04a3344 100644 --- a/src/components/Menu/types.ts +++ b/src/components/Menu/types.ts @@ -1,5 +1,9 @@ import React from 'react' -import {GestureResponderEvent, PressableProps} from 'react-native' +import { + GestureResponderEvent, + PressableProps, + AccessibilityProps, +} from 'react-native' import {Props as SVGIconProps} from '#/components/icons/common' import * as Dialog from '#/components/Dialog' @@ -9,7 +13,19 @@ export type ContextType = { control: Dialog.DialogOuterProps['control'] } -export type TriggerProps = ViewStyleProp & { +export type RadixPassThroughTriggerProps = { + id: string + type: 'button' + disabled: boolean + ['data-disabled']: boolean + ['data-state']: string + ['aria-controls']?: string + ['aria-haspopup']?: boolean + ['aria-expanded']?: AccessibilityProps['aria-expanded'] + onKeyDown: (e: React.KeyboardEvent) => void + onPointerDown: PressableProps['onPointerDown'] +} +export type TriggerProps = { children(props: TriggerChildProps): React.ReactNode label: string } @@ -52,7 +68,13 @@ export type TriggerChildProps = */ pressed: false } - props: {} + props: RadixPassThroughTriggerProps & { + onFocus: () => void + onBlur: () => void + onMouseEnter: () => void + onMouseLeave: () => void + accessibilityLabel: string + } } export type ItemProps = React.PropsWithChildren< -- cgit 1.4.1 From 5c771050bc3a807fb45abbf47af823e0ea69cf81 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 12 Mar 2024 19:10:44 -0500 Subject: Fix sensitivity while scrolling (#3190) --- src/components/Menu/index.web.tsx | 4 ++++ src/components/Menu/types.ts | 5 +++++ 2 files changed, 9 insertions(+) (limited to 'src/components/Menu/types.ts') diff --git a/src/components/Menu/index.web.tsx b/src/components/Menu/index.web.tsx index 2004ee7c6..47193bce0 100644 --- a/src/components/Menu/index.web.tsx +++ b/src/components/Menu/index.web.tsx @@ -119,6 +119,10 @@ export function Trigger({children, label}: TriggerProps) { }, props: { ...props, + // disable on web, use `onPress` + onPointerDown: () => false, + onPress: () => + control.isOpen ? control.close() : control.open(), onFocus: onFocus, onBlur: onBlur, onMouseEnter, diff --git a/src/components/Menu/types.ts b/src/components/Menu/types.ts index 7d04a3344..e710971ee 100644 --- a/src/components/Menu/types.ts +++ b/src/components/Menu/types.ts @@ -23,6 +23,10 @@ export type RadixPassThroughTriggerProps = { ['aria-haspopup']?: boolean ['aria-expanded']?: AccessibilityProps['aria-expanded'] onKeyDown: (e: React.KeyboardEvent) => void + /** + * Radix provides this, but we override on web to use `onPress` instead, + * which is less sensitive while scrolling. + */ onPointerDown: PressableProps['onPointerDown'] } export type TriggerProps = { @@ -69,6 +73,7 @@ export type TriggerChildProps = pressed: false } props: RadixPassThroughTriggerProps & { + onPress: () => void onFocus: () => void onBlur: () => void onMouseEnter: () => void -- cgit 1.4.1