Repository navigation
[iOS] Refactor Touchable not to rely on GestureDetector - #4343
Merged
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
3 of 13 tasks
j-piasecki
added a commit
that referenced
this pull request
Aug 7, 2026
## Description Documents `onHoverIn`/`onHoverOut` on the `Touchable` page, together with the behaviour that isn't obvious from the signature: how the two pair up, what `disabled` does to an open hover, which platforms report the crossings during a press, tvOS driving hover from focus, and hover state not surviving an unmount or a detach. Also refreshes the press callbacks on the same page, which still described the pre-#4342/#4343 signature. `onPress`, `onPressIn` and `onPressOut` take a `ButtonEvent` rather than a `GestureEvent<NativeHandlerData>`, and `onLongPress` takes an event at all — the old snippets additionally listed a `handlerTag` field that `ButtonEvent` does not carry, and omitted `x`/`y`/`absoluteX`/`absoluteY`. Leaving them alone would have put contradictory signatures directly above the new hover blocks. ## Test plan `yarn start` in `packages/docs-gesture-handler`.
j-piasecki
added a commit
that referenced
this pull request
Aug 7, 2026
## Description Documents `onHoverIn`/`onHoverOut` on the `Touchable` page, together with the behaviour that isn't obvious from the signature: how the two pair up, what `disabled` does to an open hover, which platforms report the crossings during a press, tvOS driving hover from focus, and hover state not surviving an unmount or a detach. Also refreshes the press callbacks on the same page, which still described the pre-#4342/#4343 signature. `onPress`, `onPressIn` and `onPressOut` take a `ButtonEvent` rather than a `GestureEvent<NativeHandlerData>`, and `onLongPress` takes an event at all — the old snippets additionally listed a `handlerTag` field that `ButtonEvent` does not carry, and omitted `x`/`y`/`absoluteX`/`absoluteY`. Leaving them alone would have put contradictory signatures directly above the new hover blocks. ## Test plan `yarn start` in `packages/docs-gesture-handler`.
j-piasecki
added a commit
that referenced
this pull request
Aug 7, 2026
## Description Documents `onHoverIn`/`onHoverOut` on the `Touchable` page, together with the behaviour that isn't obvious from the signature: how the two pair up, what `disabled` does to an open hover, which platforms report the crossings during a press, tvOS driving hover from focus, and hover state not surviving an unmount or a detach. Also refreshes the press callbacks on the same page, which still described the pre-#4342/#4343 signature. `onPress`, `onPressIn` and `onPressOut` take a `ButtonEvent` rather than a `GestureEvent<NativeHandlerData>`, and `onLongPress` takes an event at all — the old snippets additionally listed a `handlerTag` field that `ButtonEvent` does not carry, and omitted `x`/`y`/`absoluteX`/`absoluteY`. Leaving them alone would have put contradictory signatures directly above the new hover blocks. ## Test plan `yarn start` in `packages/docs-gesture-handler`.
j-piasecki
added a commit
that referenced
this pull request
Aug 10, 2026
## Description Documents `onHoverIn`/`onHoverOut` on the `Touchable` page, together with the behaviour that isn't obvious from the signature: how the two pair up, what `disabled` does to an open hover, which platforms report the crossings during a press, tvOS driving hover from focus, and hover state not surviving an unmount or a detach. Also refreshes the press callbacks on the same page, which still described the pre-#4342/#4343 signature. `onPress`, `onPressIn` and `onPressOut` take a `ButtonEvent` rather than a `GestureEvent<NativeHandlerData>`, and `onLongPress` takes an event at all — the old snippets additionally listed a `handlerTag` field that `ButtonEvent` does not carry, and omitted `x`/`y`/`absoluteX`/`absoluteY`. Leaving them alone would have put contradictory signatures directly above the new hover blocks. ## Test plan `yarn start` in `packages/docs-gesture-handler`.
j-piasecki
added a commit
that referenced
this pull request
Aug 10, 2026
## Description Documents `onHoverIn`/`onHoverOut` on the `Touchable` page, together with the behaviour that isn't obvious from the signature: how the two pair up, what `disabled` does to an open hover, which platforms report the crossings during a press, tvOS driving hover from focus, and hover state not surviving an unmount or a detach. Also refreshes the press callbacks on the same page, which still described the pre-#4342/#4343 signature. `onPress`, `onPressIn` and `onPressOut` take a `ButtonEvent` rather than a `GestureEvent<NativeHandlerData>`, and `onLongPress` takes an event at all — the old snippets additionally listed a `handlerTag` field that `ButtonEvent` does not carry, and omitted `x`/`y`/`absoluteX`/`absoluteY`. Leaving them alone would have put contradictory signatures directly above the new hover blocks. ## Test plan `yarn start` in `packages/docs-gesture-handler`.
RonenMars
added a commit
to RonenMars/threadbase-mobile
that referenced
this pull request
Aug 26, 2026
…867) Bumps \[react-native-gesture-handler\](https://github.com/software-mansion/react-native-gesture-handler) from 2.32.0 to 3.2.1. Release notes _Sourced from [react-native-gesture-handler's releases](https://github.com/software-mansion/react-native-gesture-handler/releases)._ > v3.2.1 > ------ > > 🐛 Bug fixes > ------------ > > * Forward press handlers as `testOnly_*` in `PressableWithTouchable` by [`@huextrat`](https://github.com/huextrat) in [software-mansion/react-native-gesture-handler#4416](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4416) > > 🔢 Miscellaneous > ---------------- > > * Update `Pressable` props by [`@m-bert`](https://github.com/m-bert) in [software-mansion/react-native-gesture-handler#4421](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4421) > > **Full Changelog**: [https://github.com/software-mansion/react-native-gesture-handler/compare/v3.2.0...v3.2.1](https://github.com/software-mansion/react-native-gesture-handler/compare/v3.2.0...v3.2.1) > > v3.2.0 > ------ > > ❗ Important changes > ------------------- > > * feat: Adopt AGP v9 by [`@hurali97`](https://github.com/hurali97) in [software-mansion/react-native-gesture-handler#4263](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4263) > * Implement `Pressable` based on `Touchable` by [`@m-bert`](https://github.com/m-bert) in [software-mansion/react-native-gesture-handler#4411](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4411) > * \[Android\] Add hover callbacks to Touchable by [`@j-piasecki`](https://github.com/j-piasecki) in [software-mansion/react-native-gesture-handler#4396](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4396) > * \[iOS\] Add hover callbacks to Touchable by [`@j-piasecki`](https://github.com/j-piasecki) in [software-mansion/react-native-gesture-handler#4397](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4397) > * \[Web\] Add hover callbacks to Touchable by [`@j-piasecki`](https://github.com/j-piasecki) in [software-mansion/react-native-gesture-handler#4398](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4398) > * \[Web\] Refactor `Touchable` not to rely on `GestureDetector` by [`@j-piasecki`](https://github.com/j-piasecki) in [software-mansion/react-native-gesture-handler#4344](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4344) > * \[iOS\] Refactor `Touchable` not to rely on `GestureDetector` by [`@j-piasecki`](https://github.com/j-piasecki) in [software-mansion/react-native-gesture-handler#4343](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4343) > * \[Android\] Refactor `Touchable` not to rely on `GestureDetector` by [`@j-piasecki`](https://github.com/j-piasecki) in [software-mansion/react-native-gesture-handler#4342](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4342) > * Fix fatal crash `Cannot read property 'translationX' of undefined` when a touch event is serialized without `allTouches` by [`@huextrat`](https://github.com/huextrat) in [software-mansion/react-native-gesture-handler#4316](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4316) > > 👍 Improvements > --------------- > > * \[Android\] Skip the underlay drawable when it can never be visible by [`@j-piasecki`](https://github.com/j-piasecki) in [software-mansion/react-native-gesture-handler#4359](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4359) > * \[Android\] Apply the button's managed handler config once per prop transaction by [`@j-piasecki`](https://github.com/j-piasecki) in [software-mansion/react-native-gesture-handler#4357](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4357) > * \[Android\] Configure the button's handler directly instead of through a `ReadableMap` by [`@j-piasecki`](https://github.com/j-piasecki) in [software-mansion/react-native-gesture-handler#4358](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4358) > > 🐛 Bug fixes > ------------ > > * \[Android\] Guard update events to only be dispatched in ACTIVE state by [`@j-piasecki`](https://github.com/j-piasecki) in [software-mansion/react-native-gesture-handler#4332](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4332) > * Pass empty callbacks to UI when `runOnJS` is `true` by [`@m-bert`](https://github.com/m-bert) in [software-mansion/react-native-gesture-handler#4326](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4326) > * \[Web\] Fix incorrectly calculated `timeDelta` by [`@m-bert`](https://github.com/m-bert) in [software-mansion/react-native-gesture-handler#4329](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4329) > * \[Web\] Fix incorrect `Tap` offset by [`@m-bert`](https://github.com/m-bert) in [software-mansion/react-native-gesture-handler#4330](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4330) > * Fix `minVelocity` props behavior by [`@m-bert`](https://github.com/m-bert) in [software-mansion/react-native-gesture-handler#4327](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4327) > * \[Android\] Fix `minDistance` being reset by partial config updates by [`@m-bert`](https://github.com/m-bert) in [software-mansion/react-native-gesture-handler#4347](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4347) > * Move Interceptor on `ScrollView`, not its content by [`@m-bert`](https://github.com/m-bert) in [software-mansion/react-native-gesture-handler#4331](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4331) > * \[iOS\] Re-sync layer opacity and transform from retained props when recycling buttons by [`@m-bert`](https://github.com/m-bert) in [software-mansion/react-native-gesture-handler#4360](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4360) > * \[Android\] Properly handle `requestDisallowInterceptTouchEvent` for v3 by [`@j-piasecki`](https://github.com/j-piasecki) in [software-mansion/react-native-gesture-handler#4367](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4367) > * Fix `Touchable` not respecting `keyboardShouldPersistTaps="handled"` by [`@m-bert`](https://github.com/m-bert) in [software-mansion/react-native-gesture-handler#4372](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4372) > * \[macOS\] Fix touch events never being delivered by [`@m-bert`](https://github.com/m-bert) in [software-mansion/react-native-gesture-handler#4390](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4390) > * fix: crash when mount listener fires after GestureDetector unmount by [`@kosmydel`](https://github.com/kosmydel) in [software-mansion/react-native-gesture-handler#4268](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4268) > * \[macOS\] Fix `Pan` activation criteria being ignored by [`@m-bert`](https://github.com/m-bert) in [software-mansion/react-native-gesture-handler#4387](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4387) > * \[macOS\] Fix `manualActivation` never blocking gesture activation by [`@m-bert`](https://github.com/m-bert) in [software-mansion/react-native-gesture-handler#4389](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4389) > * \[iOS\] Fix touch events never being delivered to `VirtualDetector` handlers by [`@m-bert`](https://github.com/m-bert) in [software-mansion/react-native-gesture-handler#4392](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4392) > * \[iOS\] Fix gestures attached via `VirtualGestureDetector` never recognizing continuous gestures by [`@m-bert`](https://github.com/m-bert) in [software-mansion/react-native-gesture-handler#4393](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4393) > * \[macOS\] Fix `Fling` not sending touch events and begin/end states consistently by [`@m-bert`](https://github.com/m-bert) in [software-mansion/react-native-gesture-handler#4395](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4395) > * \[Android\] Fix handlers cancelled while awaiting leaking in the orchestrator by [`@m-bert`](https://github.com/m-bert) in [software-mansion/react-native-gesture-handler#4402](https://redirect.github.com/software-mansion/react-native-gesture-handler/pull/4402) ... (truncated) Commits * [`62f0f7d`](software-mansion/react-native-gesture-handler@62f0f7d) Release v3.2.1 * [`4716425`](software-mansion/react-native-gesture-handler@4716425) Merge branch '3.2-stable' of github.com:software-mansion/react-native-gesture... * [`f0ae48c`](software-mansion/react-native-gesture-handler@f0ae48c) Update `Pressable` props ([#4421](https://redirect.github.com/software-mansion/react-native-gesture-handler/issues/4421)) * [`5f0f0d8`](software-mansion/react-native-gesture-handler@5f0f0d8) Forward press handlers as `testOnly_*` in `PressableWithTouchable` ([#4416](https://redirect.github.com/software-mansion/react-native-gesture-handler/issues/4416)) * [`0a91db7`](software-mansion/react-native-gesture-handler@0a91db7) Release v3.2.0 * [`44046a6`](software-mansion/react-native-gesture-handler@44046a6) \[Android\] Resolve the button event dispatcher by react tag ([#4415](https://redirect.github.com/software-mansion/react-native-gesture-handler/issues/4415)) * [`2469c1d`](software-mansion/react-native-gesture-handler@2469c1d) Derive `Pressable` pressed state from `testOnly_pressed` ([#4414](https://redirect.github.com/software-mansion/react-native-gesture-handler/issues/4414)) * [`3f1bf74`](software-mansion/react-native-gesture-handler@3f1bf74) Clear pending timers on unmount in StatefulPressable ([#4413](https://redirect.github.com/software-mansion/react-native-gesture-handler/issues/4413)) * [`50ae6a1`](software-mansion/react-native-gesture-handler@50ae6a1) \[General\] Default GestureDetector moduleId to -1 ([#4412](https://redirect.github.com/software-mansion/react-native-gesture-handler/issues/4412)) * [`8b661c9`](software-mansion/react-native-gesture-handler@8b661c9) Implement `Pressable` based on `Touchable` ([#4411](https://redirect.github.com/software-mansion/react-native-gesture-handler/issues/4411)) * Additional commits viewable in [compare view](software-mansion/react-native-gesture-handler@v2.32.0...v3.2.1)
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