Skip to content

[iOS] Fix enabled state diverging between the handler and its recognizer#4140

Open
j-piasecki wants to merge 1 commit intomainfrom
@jpiasecki/fix-ios-disabled-handlers
Open

[iOS] Fix enabled state diverging between the handler and its recognizer#4140
j-piasecki wants to merge 1 commit intomainfrom
@jpiasecki/fix-ios-disabled-handlers

Conversation

@j-piasecki
Copy link
Copy Markdown
Member

@j-piasecki j-piasecki commented Apr 30, 2026

Description

Since some recognizers changed their own state in reset, it was possible for the value to desync between the recognizer and the handler. This could lead to issues where a "disabled" handler would block other gestures from firing.

This PR:

  • removes explicit enabled = YES from pan gesture, since it never changes the value by itself
  • replaces enabled = YES with enabled = _gestureHandler.enabled for tap, since it can set its own enabled to NO to cancel itself
  • removes shouldBeRequiredToFailByGestureRecognizer from the root recognizer - it was added in de0ffb4, before aligning enabled between recognizer and handler in a64b425. Disabled recognizers should never be considered for recognition, so this is effectively a no-op.

Test plan

Tested on the provided repro: https://github.com/pawicao/rngh-v3-testing/blob/enabled-repro/src/app/index.tsx

Zoom in, pan around, zoom out, try to scroll horizontally

Copilot AI review requested due to automatic review settings April 30, 2026 11:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes an iOS edge case where a gesture handler’s enabled value could get out of sync with its underlying UIGestureRecognizer, causing “disabled” handlers to still interfere with other gestures (e.g., blocking recognition / canceling RN responders unexpectedly).

Changes:

  • Removes a root-level failure-requirement override that attempted to account for disabled handlers at the root recognizer level.
  • Aligns tap recognizer enabled on reset with the backing handler’s enabled.
  • Removes an unnecessary enabled = YES in pan recognizer reset (since pan doesn’t mutate enabled itself).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/react-native-gesture-handler/apple/RNRootViewGestureRecognizer.m Removes root recognizer logic that imposed failure requirements based on handler enabled.
packages/react-native-gesture-handler/apple/Handlers/RNTapHandler.m Ensures tap recognizer enabled is restored to match _gestureHandler.enabled during reset.
packages/react-native-gesture-handler/apple/Handlers/RNPanHandler.m Removes redundant enabled = YES in reset to avoid unnecessary state churn.

💡 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

2 participants