Skip to content

Pressable not triggering onPress via mouse interaction on android #3889

@hebaselim

Description

@hebaselim

Description

When using a mouse on Android devices, Pressable from react-native-gesture-handler only triggers onPress and onPressIn on right-click, not left-click. Left-clicks are completely ignored and don't fire any press events.

Steps to reproduce

  1. Create a React Native app with react-native-gesture-handler version 2.29.0
  2. Add a Pressable component with onPress handler
  3. Connect a physical mouse to an Android device
  4. Left-click on the Pressable - nothing happens
  5. Right-click on the Pressable - onPress fires

Expected behavior
Left-click should trigger the onPress handler, as it's the primary mouse button. Right-click should either be ignored or trigger a context menu, but not the press handler.

Actual behavior
Left-click: No response, onPress and onPressIn are not called
Right-click: onPress and onPressIn are both called

Additional context

This issue affects users who rely on mouse input for accessibility
event.nativeEvent.button is always undefined in both onPress and onPressIn, so there's no way to distinguish between mouse buttons in JavaScript
Previously used TouchableOpacity in version 2.27.1 which correctly handled both left and right clicks (though both triggered the press event)
After upgrading to 2.29.0 and migrating to Pressable (as TouchableOpacity is deprecated), this regression appeared

A link to a Gist, an Expo Snack or a link to a repository based on this template that reproduces the bug.

https://gist.github.com/terreng/323e54a4eb2ca0eaecd605dc2054a9bc

Gesture Handler version

2.2.9.0

React Native version

0.79.5

Platforms

Android

JavaScript runtime

None

Workflow

React Native (without Expo)

Architecture

Old Architecture (Paper)

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions