Skip to content

fix(ios): clean up gesture recognizer targets on sheet dismiss#609

Open
davidecallegaro wants to merge 1 commit intolodev09:mainfrom
davidecallegaro:fix/cleanup-gesture-recognizers-on-dismiss
Open

fix(ios): clean up gesture recognizer targets on sheet dismiss#609
davidecallegaro wants to merge 1 commit intolodev09:mainfrom
davidecallegaro:fix/cleanup-gesture-recognizers-on-dismiss

Conversation

@davidecallegaro
Copy link
Copy Markdown

Summary

  • setupGestureRecognizer adds handlePanGesture: as a target to the presented view's and inner ScrollView's pan gesture recognizers via addTarget:action:, but there is no corresponding removeTarget:action: when the sheet disappears
  • This leaves orphaned gesture handler targets that block scroll events on the presenting view controller when navigating away and returning (e.g. in a React Navigation stack)

Changes

  • GestureUtil: Added detachPanGestureHandler:target:selector: to mirror attachPanGestureHandler
  • TrueSheetViewController: Added cleanupGestureRecognizer method
    • Called in viewWillDisappear: to remove targets before the view disappears
    • Re-attaches in viewDidAppear: when the sheet reappears (e.g. after a child sheet is dismissed)

Reproduction

  1. Present a TrueSheet with scrollable={true} on a screen
  2. Navigate to another screen (push) while the sheet is presented
  3. Navigate back
  4. The presenting screen's ScrollView is frozen — cannot scroll, but buttons still work

Test plan

  • Open sheet → navigate away → return: scroll works
  • Open sheet → present child sheet → dismiss child: parent sheet drag still works
  • Open sheet → dismiss normally: no regression

setupGestureRecognizer adds handlePanGesture: as a target to both the
presented view's and the inner ScrollView's pan gesture recognizers via
addTarget:action:. However, there is no corresponding removeTarget:action:
call when the sheet disappears. This leaves orphaned gesture handler
targets that can block scroll events on the presenting view controller
when navigating away and returning.

This commit:
- Adds GestureUtil.detachPanGestureHandler to mirror attachPanGestureHandler
- Adds cleanupGestureRecognizer to TrueSheetViewController
- Calls cleanup in viewWillDisappear to remove targets before the view
  disappears
- Re-attaches in viewDidAppear when the sheet reappears (e.g. after a
  child sheet is dismissed)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 19, 2026

@davidecallegaro is attempting to deploy a commit to the Jovanni's projects Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-native-true-sheet Ready Ready Preview, Comment Mar 19, 2026 5:00pm

Request Review

Copy link
Copy Markdown
Owner

@lodev09 lodev09 left a comment

Choose a reason for hiding this comment

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

LGTM. Just update changelog and is good to merge.
Thanks!

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.

2 participants