Skip to content

fix(Android): apply numberOfPointers config to the pointer requirement in LongPressGestureHandler#4253

Open
prashanFOMO wants to merge 1 commit into
software-mansion:mainfrom
prashanFOMO:fix-android-longpress-number-of-pointers
Open

fix(Android): apply numberOfPointers config to the pointer requirement in LongPressGestureHandler#4253
prashanFOMO wants to merge 1 commit into
software-mansion:mainfrom
prashanFOMO:fix-android-longpress-number-of-pointers

Conversation

@prashanFOMO

Copy link
Copy Markdown

Description

Fixes #4252

On Android, the numberOfPointers config of the LongPress gesture has been silently ignored since 2.26.0: a gesture configured with Gesture.LongPress().numberOfPointers(3) activates after a single-pointer long press, and can never activate with the configured pointer count (the second pointer trips currentPointers > numberOfPointersRequired and fails the handler). iOS is unaffected, since the prop maps to UILongPressGestureRecognizer.numberOfTouchesRequired.

The cause is a one-line mix-up introduced by the factory refactor in 2.26.0. The factory's updateConfig assigns the config value to handler.numberOfPointers, which resolves to the inherited GestureHandler.numberOfPointers — the live pointer-count used for event payloads, overwritten with event.pointerCount on every motion event. The field that actually gates activation, numberOfPointersRequired, stays at its default of 1 and is never written from config. Before 2.26.0, the module factory called handler.setNumberOfPointers(...), which set numberOfPointersRequired correctly.

This PR routes the config value to numberOfPointersRequired, restoring the pre-2.26 behavior. The private-field access from the nested Factory matches the existing maxDist assignment directly above.

Test plan

  • Applied this same one-liner to 2.28.0 via patch-package in an RN 0.81.5 (Expo 54, new architecture, Hermes) app that uses Gesture.LongPress().numberOfPointers(3) as a global gesture, and verified on an Android device:
    • three-pointer long press now activates the gesture (previously never fired)
    • single-pointer long press no longer activates it (previously fired after ~500 ms)
    • gestures with the default single pointer (no numberOfPointers set) are unaffected
  • Verified iOS behavior is unchanged (the fix doesn't touch the iOS path)
  • Repro snippet: https://gist.github.com/prashanFOMO/ad838ce8a3c77c59759b8583fe8d3393

…t in LongPressGestureHandler

updateConfig was assigning the numberOfPointers config value to the
inherited GestureHandler.numberOfPointers property (the live pointer
count reported in event payloads, overwritten on every motion event)
instead of numberOfPointersRequired, which gates activation and stayed
at its default of 1. As a result, on Android a LongPress gesture with
numberOfPointers > 1 activated with a single pointer and could never
activate with the configured pointer count (the second pointer trips
currentPointers > numberOfPointersRequired and fails the gesture).
Copilot AI review requested due to automatic review settings June 10, 2026 18:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates Android LongPressGestureHandler configuration to map the KEY_NUMBER_OF_POINTERS value onto the handler’s “required pointers” property.

Changes:

  • Route KEY_NUMBER_OF_POINTERS config to numberOfPointersRequired instead of numberOfPointers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants