Skip to content

LongPress numberOfPointers is ignored on Android — activates with a single pointer (regression in 2.26.0) #4252

@prashanFOMO

Description

@prashanFOMO

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

  1. Render the snippet from the gist below (a full-screen GestureDetector with Gesture.LongPress().numberOfPointers(3)) in an Android app
  2. Long-press with one finger → onStart fires after ~500 ms (it shouldn't)
  3. Long-press with three fingers → onStart never fires (it should)
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions