Skip to content

fix(ios): dismiss a sheet that is unmounted while still presented - #859

Closed
SamuelBrucksch wants to merge 2 commits into
lodev09:mainfrom
SamuelBrucksch:fix/ios-dismiss-on-recycle
Closed

SamuelBrucksch wants to merge 2 commits into
lodev09:mainfrom
SamuelBrucksch:fix/ios-dismiss-on-recycle

Conversation

@SamuelBrucksch

Copy link
Copy Markdown
Contributor

Summary

On iOS, a TrueSheet that is unmounted while still presented stays on screen: fully drawn, dead to touches, and gone from the accessibility tree, until the user swipes it away. Only a mid-dismissal controller was handled in prepareForRecycle; a presented one was left alone. dealloc would dismiss it, but Fabric pools the host view, so dealloc never runs in practice. Android already dismisses in onDropInstance.

This dismisses the controller in prepareForRecycle when it is still presented (nil-ing the delegate first, so no events reach the unmounted JS side), and lets the existing mid-dismissal block take it from there.

Minimal repro on main:

const [show, setShow] = useState(true)

<Button title="Unmount" onPress={() => setShow(false)} />
{show && (
  <TrueSheet initialDetentIndex={0} detents={['auto']}>
    <Text>Unmount me without dismissing</Text>
  </TrueSheet>
)}

Before: the sheet remains after "Unmount"; nothing behind it can be tapped. After: it animates out like a dismiss().

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Test Plan

  • Unmounted a presented sheet by conditionally rendering it (as above) — the sheet dismisses, the screen underneath is interactive again, and a fresh mount presents normally.
  • Unmounted a sheet that was presented over another sheet — the parent regains focus (emitDidDismissEvents still runs in viewDidDisappear, so _isPresented resets and the parent's focus callbacks fire).
  • Regression: dismiss(), swipe-to-dismiss, dim tap, and unmounting mid-dismissal (the existing isBeingDismissed path) behave as before; no TrueSheet: warnings in the system log.

Screenshots / Videos

n/a

Checklist

  • I tested on iOS
  • I tested on Android (no Android change)
  • I tested on Web (no Web change)
  • I updated the documentation (if needed)
  • I added a changelog entry (if needed)

@vercel

vercel Bot commented Sep 19, 2026

Copy link
Copy Markdown

@SamuelBrucksch is attempting to deploy a commit to the lodev09 Team on Vercel.

A member of the Team first needs to authorize it.

@SamuelBrucksch
SamuelBrucksch marked this pull request as ready for review September 19, 2026 05:09
@lodev09

lodev09 commented Sep 20, 2026

Copy link
Copy Markdown
Owner

This is breaking with react-navigation screens + undimmed sheets. When you dismiss a screen with a presented sheet, ios waits for the sheet animation to finish before the screen dismisses causing bad UX. You can compare behavior in the example app.

@lodev09 lodev09 closed this Sep 20, 2026
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