Description
Since 2.26.0, the numberOfPointers config of the LongPress gesture is silently ignored on Android. A gesture configured with Gesture.LongPress().numberOfPointers(3):
- activates after a single-pointer long press (the configured pointer count is never applied), and
- can never activate with the configured pointer count — as soon as the second pointer touches down,
currentPointers > numberOfPointersRequired (2 > 1) trips and the handler fails.
iOS is unaffected (numberOfPointers maps to UILongPressGestureRecognizer.numberOfTouchesRequired).
Root cause: in the 2.26.0 refactor that moved handler configuration from RNGestureHandlerModule into the nested Factory classes, the LongPress factory's config assignment ended up targeting the wrong property. In LongPressGestureHandler.kt:
if (config.hasKey(KEY_NUMBER_OF_POINTERS)) {
handler.numberOfPointers = config.getInt(KEY_NUMBER_OF_POINTERS)
}
handler.numberOfPointers resolves to the inherited GestureHandler.numberOfPointers — the live "pointers currently down" counter used for event payloads, which the base class overwrites with event.pointerCount on every motion event. The field that actually gates activation, private var numberOfPointersRequired, stays at its init value of 1 and is never written from config.
Before 2.26.0, the module factory called handler.setNumberOfPointers(...), which correctly set numberOfPointersRequired.
Verified present in 2.26.0, 2.27.x, 2.28.0, 2.29.1, 3.0.0, and current main (by inspecting the published packages). Verified the one-line fix on-device (Android, RN 0.81.5) via a patched 2.28.0.
Fix PR incoming — routing the config value to numberOfPointersRequired, restoring the pre-2.26 behavior.
Steps to reproduce
- Render the snippet from the gist below (a full-screen
GestureDetector with Gesture.LongPress().numberOfPointers(3)) in an Android app
- Long-press with one finger →
onStart fires after ~500 ms (it shouldn't)
- Long-press with three fingers →
onStart never fires (it should)
- Run the same snippet on iOS → behaves correctly (fires only with exactly 3 fingers)
Snack or a link to a repository
https://gist.github.com/prashanFOMO/ad838ce8a3c77c59759b8583fe8d3393
Gesture Handler version
2.28.0 (present in 2.26.0 through 3.0.0 and current main)
React Native version
0.81.5
Platforms
Android
JavaScript runtime
Hermes
Workflow
Expo Dev Client
Architecture
Fabric (New Architecture)
Build type
Debug app & dev bundle
Device
Real device
Device model
No response
Acknowledgements
Yes
Description
Since 2.26.0, the
numberOfPointersconfig of the LongPress gesture is silently ignored on Android. A gesture configured withGesture.LongPress().numberOfPointers(3):currentPointers > numberOfPointersRequired(2 > 1) trips and the handler fails.iOS is unaffected (
numberOfPointersmaps toUILongPressGestureRecognizer.numberOfTouchesRequired).Root cause: in the 2.26.0 refactor that moved handler configuration from
RNGestureHandlerModuleinto the nestedFactoryclasses, the LongPress factory's config assignment ended up targeting the wrong property. InLongPressGestureHandler.kt:handler.numberOfPointersresolves to the inheritedGestureHandler.numberOfPointers— the live "pointers currently down" counter used for event payloads, which the base class overwrites withevent.pointerCounton every motion event. The field that actually gates activation,private var numberOfPointersRequired, stays at its init value of1and is never written from config.Before 2.26.0, the module factory called
handler.setNumberOfPointers(...), which correctly setnumberOfPointersRequired.Verified present in 2.26.0, 2.27.x, 2.28.0, 2.29.1, 3.0.0, and current
main(by inspecting the published packages). Verified the one-line fix on-device (Android, RN 0.81.5) via a patched 2.28.0.Fix PR incoming — routing the config value to
numberOfPointersRequired, restoring the pre-2.26 behavior.Steps to reproduce
GestureDetectorwithGesture.LongPress().numberOfPointers(3)) in an Android apponStartfires after ~500 ms (it shouldn't)onStartnever fires (it should)Snack or a link to a repository
https://gist.github.com/prashanFOMO/ad838ce8a3c77c59759b8583fe8d3393
Gesture Handler version
2.28.0 (present in 2.26.0 through 3.0.0 and current main)
React Native version
0.81.5
Platforms
Android
JavaScript runtime
Hermes
Workflow
Expo Dev Client
Architecture
Fabric (New Architecture)
Build type
Debug app & dev bundle
Device
Real device
Device model
No response
Acknowledgements
Yes