[iOS] Refactor Touchable not to rely on GestureDetector#4343
Merged
Conversation
j-piasecki
force-pushed
the
touchable-refactor
branch
from
July 27, 2026 05:59
c233824 to
496a9c1
Compare
j-piasecki
force-pushed
the
touchable-refactor-ios
branch
from
July 27, 2026 06:00
1e89ff8 to
4355487
Compare
j-piasecki
force-pushed
the
touchable-refactor-ios
branch
from
July 27, 2026 06:24
4355487 to
233649d
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors v3 Touchable on iOS to stop relying on GestureDetector and instead drive press interactions via a managed NativeViewGestureHandler + native button state machine, aligning iOS behavior more closely with Android and simplifying JS-side logic.
Changes:
- Introduces native-side observer hooks (
dispatchStateChange/dispatchHandlerUpdate) soRNNativeViewGestureHandlercan forward state/update information to the bound view (needed forUIControlcases). - Namespaces button press events (
onButtonPress*) and updates JS components/tests to consume button events rather than gesture state sequences. - Splits
Touchableimplementation: shared native (Touchable.tsx) uses button events; web (Touchable.web.tsx) keeps the JS gesture-driven implementation; removesTouchable.android.tsx.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/react-native-gesture-handler/src/v3/components/Touchable/TouchableProps.ts | Updates omitted native button event prop names to onButton* so Touchable can own the mapping. |
| packages/react-native-gesture-handler/src/v3/components/Touchable/Touchable.web.tsx | Adds web-specific implementation retaining JS gesture-driven press behavior. |
| packages/react-native-gesture-handler/src/v3/components/Touchable/Touchable.tsx | Switches native platforms to use GestureHandlerButton’s namespaced button events + managed handler props. |
| packages/react-native-gesture-handler/src/v3/components/Touchable/Touchable.android.tsx | Removes Android-only implementation in favor of shared native Touchable.tsx. |
| packages/react-native-gesture-handler/src/v3/components/GestureButtonsProps.ts | Updates omitted native event prop names to onButton*. |
| packages/react-native-gesture-handler/src/specs/RNGestureHandlerButtonNativeComponent.ts | Renames native event props to onButton* and adds moduleId prop (iOS-only usage). |
| packages/react-native-gesture-handler/src/components/GestureHandlerButton.tsx | Updates public TS types to namespaced button events and adds moduleId. |
| packages/react-native-gesture-handler/src/tests/mocks.test.tsx | Updates tests to fire button events (buttonPress) instead of gesture state changes. |
| packages/react-native-gesture-handler/src/tests/api_v3.test.tsx | Updates v3 component tests to simulate native button event sequences (including cancel / long-press). |
| packages/react-native-gesture-handler/apple/RNGestureHandlerManager.mm | Adds support for RNGestureHandlerActionTypeNone (consume natively, don’t dispatch to JS). |
| packages/react-native-gesture-handler/apple/RNGestureHandlerButtonComponentView.mm | Creates/updates/drops a managed NativeViewGestureHandler and dispatches onButton* events via Fabric emitter. |
| packages/react-native-gesture-handler/apple/RNGestureHandlerButton.mm | Implements native press state machine + native long-press timer driven by managed handler state/updates. |
| packages/react-native-gesture-handler/apple/RNGestureHandlerButton.h | Adds button event delegate protocol + managed handler tracking properties. |
| packages/react-native-gesture-handler/apple/RNGestureHandlerActionType.h | Adds RNGestureHandlerActionTypeNone. |
| packages/react-native-gesture-handler/apple/RNGestureHandler.mm | Adds overridable dispatchStateChange / dispatchHandlerUpdate hooks after event dispatch. |
| packages/react-native-gesture-handler/apple/RNGestureHandler.h | Declares the new overridable dispatch hooks. |
| packages/react-native-gesture-handler/apple/Handlers/RNNativeViewHandler.mm | Tracks bound view for UIControl scenarios and forwards handler updates/state changes to observer protocol. |
| packages/react-native-gesture-handler/apple/Handlers/RNNativeViewHandler.h | Adds RNGHNativeViewHandlerStateObserver protocol for bound views to observe updates/state changes. |
| packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt | Adds no-op moduleId prop setter on Android (iOS-only behavior). |
| packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/events/RNGestureHandlerButtonEvent.kt | Renames Android button event names to onButton* for cross-platform consistency. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
j-piasecki
force-pushed
the
touchable-refactor-ios
branch
from
July 27, 2026 07:32
233649d to
71d694d
Compare
m-bert
approved these changes
Jul 27, 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
RNGestureHandlergains overridabledispatchStateChange/dispatchHandlerUpdatehooks.RNNativeViewGestureHandlerforwards them to its bound view through the newRNGHNativeViewHandlerStateObserverprotocol (it now keeps a_boundViewreference, since forUIControl-based views the recognizer is never attached andrecognizer.viewcan't be used).RNGestureHandlerButtonimplements the same press state machine as Android, including the native long-press timer.RNGestureHandlerButtonComponentViewcreates/updates/drops the managedNativeViewGestureHandler(attached with the newRNGestureHandlerActionTypeNone, so nothing is sent to JS) and emits the press events through the codegen event emitter. On iOS the handler manager can't be resolved from the view's context, so a newmoduleIdprop is used to look it up (no-op on Android).onButtonPressetc., because the base iOS view config already registerstopPressas a bubbling event — a direct event with the same top-level name fails view-config validation in dev.Touchable.android.tsxis replaced by a sharedTouchable.tsxused on all native platforms; the previous JS gesture-driven implementation moves toTouchable.web.tsx(removed in the next PR).Test plan
Existing tests in the Example app