[Android] Fix mouse interactions#4265
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes an Android regression where mouse click events stopped reaching gesture handlers after generic motion dispatching was restricted to hover-only events. This restores mouse button event propagation and updates gesture-handler filtering logic to consistently ignore redundant touch-stream events when a mouse is used.
Changes:
- Dispatch
ACTION_BUTTON_PRESS/ACTION_BUTTON_RELEASEthroughdispatchGenericMotionEventso mouse clicks reach the orchestrator. - Add button-press awareness to
LongPressGestureHandlerso mouse long-press can trigger its timeout. - Rename/invert mouse-event filtering helper from
shouldActivateWithMousetoshouldSkipEventand remove obsolete SDK branching.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt | Routes mouse button generic motion events (in addition to hover) into GH dispatching. |
| packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/Extensions.kt | Adds MotionEvent.isButtonAction() helper to detect button press/release actions. |
| packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt | Reworks mouse filtering into shouldSkipEvent to drop redundant touch-stream events and wrong-button input. |
| packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/TapGestureHandler.kt | Updates call site to use the new shouldSkipEvent filter. |
| packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/PanGestureHandler.kt | Updates call site to use the new shouldSkipEvent filter. |
| packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/LongPressGestureHandler.kt | Updates call site to use shouldSkipEvent and starts long-press timeout on ACTION_BUTTON_PRESS. |
| packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/FlingGestureHandler.kt | Updates call site to use the new shouldSkipEvent filter. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
j-piasecki
approved these changes
Jun 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
#3850 restricted dispatching of generic motion events to only hover events. This caused a regression in which mouse events stopped being dispatched to handlers.
This PR allows mouse events to be dispatched to handlers and adds check for mouse button press in Long Press so it can activate timeout.
It also removes check for obsolete SDK version and inverts logic of skipping events -
shouldActivateWithMousewasn't very descriptive (especially inonHandle), so I renamed it toshouldSkipEventinstead.Fixes #3889
Test plan
Tested on mouse buttons and Pressable examples