Skip to content

[iOS] Fix hooks API not cancelling JS Responder - #4261

Merged
j-piasecki merged 1 commit into
mainfrom
@jpiasecki/fix-hook-api-not-cancelling-js-responder
Jun 15, 2026
Merged

[iOS] Fix hooks API not cancelling JS Responder#4261
j-piasecki merged 1 commit into
mainfrom
@jpiasecki/fix-hook-api-not-cancelling-js-responder

Conversation

@j-piasecki

Copy link
Copy Markdown
Member

Description

Fixes #4258

JS-responder cancellation relies on RNRootViewGestureRecognizer being installed on the surface view. The legacy path installs it in maybeBindHandler via registerViewWithGestureRecognizerAttachedIfNeeded, but the hook-API detector attached handlers straight to the registry and skipped that step, so activation could never cancel the JS responder.

This PR adds attachHandlerForDetectorWithTag:toView:withActionType:withHostDetector: on RNGestureHandlerManager which handles that.

Test plan

Tested on the issue reproducer

Copilot AI review requested due to automatic review settings June 15, 2026 07:29

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

Fixes iOS hook-API GestureDetector activation not cancelling the JS responder by ensuring RNRootViewGestureRecognizer gets installed on the appropriate surface/touch-handler view when detectors attach handlers (matching the legacy attach path behavior).

Changes:

  • Added attachHandlerForDetectorWithTag:toView:withActionType:withHostDetector: to RNGestureHandlerManager to attach a handler and register the surface view for JS-responder cancellation.
  • Updated RNGestureHandlerDetector to route detector-driven handler attachment through the new manager method (instead of attaching directly via the registry).

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/RNGestureHandlerManager.mm Adds a detector-specific attach helper that also installs the root gesture recognizer via registerViewWithGestureRecognizerAttachedIfNeeded:.
packages/react-native-gesture-handler/apple/RNGestureHandlerManager.h Exposes the new manager attach helper for use by the detector.
packages/react-native-gesture-handler/apple/RNGestureHandlerDetector.mm Switches detector attachment sites to use the new manager helper so JS responder cancellation can occur.

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

@j-piasecki
j-piasecki merged commit 9938977 into main Jun 15, 2026
4 checks passed
@j-piasecki
j-piasecki deleted the @jpiasecki/fix-hook-api-not-cancelling-js-responder branch June 15, 2026 09:25
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.

[iOS] Hook-API GestureDetector: gesture activation doesn't cancel the JS responder - RN Pressable underneath fires alongside the gesture

3 participants