diff --git a/src/components/Button.tsx b/src/components/Button.tsx index f69b1b7bc..ce9b940fc 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -235,6 +235,17 @@ export const Button = forwardRef( const onPointerLeave = useCallback(() => { clearLongPressTimer() }, [clearLongPressTimer]) + const onContextMenu = useCallback( + (e: Event) => { + if (!onLongPressOuter || !IS_WEB || IS_WEB_TOUCH_DEVICE) return + + e.preventDefault() + clearLongPressTimer() + longPressTriggeredRef.current = true + onLongPressOuter(e as unknown as GestureResponderEvent) + }, + [clearLongPressTimer, onLongPressOuter], + ) const onHoverIn = useCallback( (e: MouseEvent) => { setState(s => ({ @@ -604,7 +615,7 @@ export const Button = forwardRef( onPointerDown, onPointerUp, onPointerLeave, - onContextMenu: (e: Event) => e.preventDefault(), + onContextMenu, } : {}) as any)} // @ts-ignore - this will always be a pressable @@ -630,7 +641,9 @@ export const Button = forwardRef( onPressIn={onPressIn} onPressOut={onPressOut} onPress={onPress} - onLongPress={!IS_WEB || IS_WEB_TOUCH_DEVICE ? onLongPressOuter : undefined} + onLongPress={ + !IS_WEB || IS_WEB_TOUCH_DEVICE ? onLongPressOuter : undefined + } onHoverIn={onHoverIn} onHoverOut={onHoverOut} onFocus={onFocus}