Skip to content

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

Merged
j-piasecki merged 1 commit into
software-mansion:mainfrom
prashanFOMO:fix-android-longpress-number-of-pointers
Jun 11, 2026
Merged

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

Conversation

@prashanFOMO

Copy link
Copy Markdown
Contributor

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.

@j-piasecki j-piasecki left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks ❤️!

@j-piasecki j-piasecki merged commit a70c6e3 into software-mansion:main Jun 11, 2026
3 checks passed
m-bert pushed a commit that referenced this pull request Jun 11, 2026
…t in LongPressGestureHandler (#4253)

## 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
m-bert added a commit that referenced this pull request Jun 11, 2026
## Description

Cherry pick thread for release 2.32

## List of PRs

| PR  | Original commit |  Picked commit | Without confilct | 
|:----------:|:-------------:|:------:|:--------:|
| [[Android] Remove
`getChildInDrawingOrderAtIndex`](#4156)
|
[f1f09bc](f1f09bc)
|
[d76f2d9](d76f2d9)
| ❌ |
| [[iOS] Fix duplicated
`testID`](#4186)
|
[7feab6e](7feab6e)
|
[d1173ec](d1173ec)
| ❌ |
| [[Android] Fix discrete gestures not triggering
`onFinalize`](#4196)
|
[117087e](117087e)
|
[06212cf](06212cf)
| ✅ |
| [[Android] Fix wrong reported number of
pointers](#4218)
|
[f17bcbd](f17bcbd)
|
[5fd30f6](5fd30f6)
| ❌ |
| [fix(pods): Fix invalid `react-native/../react-native` resolution for
aliases](#4232)
|
[9a9f8b4](9a9f8b4)
|
[cacf6c0](cacf6c0)
| ✅ |
| [Move ruby utils to
module](#4245)
|
[62d0d52](62d0d52)
|
[3884f30](3884f30)
| ❌ |
| [[iOS] Fix handler retrieval and mismatched coordinate
space](#4199)
|
[b1da40b](b1da40b)
|
[2b48a8e](2b48a8e)
| ❌ |
| [[iOS] Don't iterate to root while resolving
recognizer](#4202)
|
[fba4dcc](fba4dcc)
|
[b81f2aa](b81f2aa)
| ❌ |
| [Support React Native
0.86](#4166)
|
[96dfc00](96dfc00)
|
[7df6d1a](7df6d1a)
| ❌ |
| [Fix `RNRenderer` import for React Native
0.86](#4160)
|
[0417378](0417378)
|
[6775d33](6775d33)
| ❌ |
| [Bump `expo` to stable
56](#4227)
|
[45e6ac8](45e6ac8)
|
[0478bb5](0478bb5)
| ❌ |
| [[macOS] Bump example
app](#3993)
|
[8ec0820](8ec0820)
|
[cfc5dd4](cfc5dd4)
| ❌ |
| [Bump
Reanimated](#4040)
|
[23d96d9](23d96d9)
|
[a2101eb](a2101eb)
| ❌ |
| [fix(Android): apply `numberOfPointers` config to the pointer
requirement in
`LongPressGestureHandler`](#4253)
|
[a70c6e3](a70c6e3)
|
[af40f9b](af40f9b)
| ✅ |

## Test plan

Tested that example apps are built correctly

---------

Co-authored-by: Pieter De Baets <pieter.debaets@gmail.com>
Co-authored-by: Mathieu Acthernoene <zoontek@gmail.com>
Co-authored-by: Jakub Piasecki <jakub.piasecki@swmansion.com>
Co-authored-by: Phil Pluckthun <phil@kitten.sh>
Co-authored-by: prashanFOMO <prashan@fomo.family>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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)

3 participants