Skip to content

[iOS] usePreventRemove callback not called when tapping formSheet backdrop #3568

@iankberry

Description

@iankberry

Description

Opening this issue per this related issue in the react-navigation repository.

I am building a form sheet that contains an input component for the user to write a note. I am also using the usePreventRemove hook to prevent the user from accidentally losing data if they tap the backdrop as this immediately closes and unmounts the sheet.

On Android, the usePreventRemove hook properly prevents the sheet from closing and the callback is emitted allowing me to alert the user. However on iOS, while the usePreventRemove hook does prevent sheet from closing, the callback param is not called. It's also worth noting that if you attempt to interactively dismiss the sheet, the callback is properly called. So this seems to be related to the backdrop specifically.

Note, the version of RN screens in the snack is 4.16.0 but I also reproduced the issue with the latest version, 4.20.0. For some reason the snack wasn't letting me upgrade to the latest version because it's not tested with Expo 54.

Steps to reproduce

  1. Open the snack in an iOS simulator
  2. Tap "Open sheet"
  3. Tap "Toggle prevent remove" in the sheet
  4. Tap the backdrop, notice the sheet does not dismiss but nothing is logged
  5. Attempt to interactively dismiss the sheet, the sheet does not dismiss and "Prevented sheet removal!" is logged

Snack or a link to a repository

https://snack.expo.dev/@iankberry/formsheet-prevent-remove-cb

Screens version

4.16.0

React Native version

0.81.5

Platforms

iOS

JavaScript runtime

Hermes

Workflow

Expo bare workflow

Architecture

Fabric (New Architecture)

Build type

Debug mode

Device

iOS simulator

Device model

No response

Acknowledgements

Yes

Metadata

Metadata

Assignees

Labels

Platform: iOSThis issue is specific to iOSRepro providedA reproduction with a snack or repo is provided

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions