[Native] Fix host detector when used alongside Activity#3967
[Native] Fix host detector when used alongside Activity#3967j-piasecki merged 3 commits intomainfrom
Activity#3967Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a regression where hook-based gestures stop working when used inside React 19.2 <Activity> on Android by ensuring gesture handlers can be recreated and host-detector-attached handlers survive window detach/attach cycles.
Changes:
- Reset
currentGestureRefwhen dropping a hook gesture handler so it can be recreated later. - Update Android Host Detector view to detach/re-attach handlers on window detach/attach.
- Switch detector view manager teardown to explicitly detach all handlers on view drop.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| packages/react-native-gesture-handler/src/v3/hooks/useGesture.ts | Resets the stored “current gesture” ref on cleanup to allow handler recreation after dropping. |
| packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerDetectorViewManager.kt | Ensures handlers are detached during view drop via detachAllHandlers(). |
| packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerDetectorView.kt | Adds attach/detach window lifecycle handling and expands detachAllHandlers() to include native handlers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...ler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerDetectorView.kt
Outdated
Show resolved
Hide resolved
...ler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerDetectorView.kt
Show resolved
Hide resolved
...roid/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerDetectorViewManager.kt
Show resolved
Hide resolved
...ler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerDetectorView.kt
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...ler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerDetectorView.kt
Show resolved
Hide resolved
...ler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerDetectorView.kt
Outdated
Show resolved
Hide resolved
...ler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerDetectorView.kt
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
Fixes #3965
There were two parts to this isse:
currentGestureRefwas never reset, so the gesture was never recreated after being droppedThis PR updates
useGestureso that it resets thecurrentGestureRefafter dropping the handler. It also updates the Android implementation of the Host Detector component to store all attached handlers on window detach and reattaches them after window attach.Test plan
See the reproduction from the linked issue.