Skip to content

Conversation

@okwasniewski
Copy link
Contributor

@okwasniewski okwasniewski commented May 20, 2025

Summary:

This PR allows to interactively close the modal using the swipe down gesture.

It fixes 5 year old issue: #29319

In short it removes modalInPresentation which according to the documentation causes: "UIKit ignores events outside the view controller’s bounds and prevents the interactive dismissal of the view controller while it is onscreen.".

It also adds another delegate event to call onRequestClose whenever modal is closed by gesture.

CleanShot.2025-05-20.at.22.35.46.mp4

Changelog:

[IOS] [ADDED] - Allow to interactively swipe down the modal.
Add allowSwipeDismissal prop.

Test Plan:

Test if swiping down the modal calls onRequestClose

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Callstack Partner: Callstack Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels May 20, 2025
@facebook-github-bot
Copy link
Contributor

@rshest has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@javache
Copy link
Member

javache commented May 21, 2025

This is only changing the new architecture component. Should we do the same for legacy arch for consistency?

This also needs a breaking changelog entry, and perhaps some more warnings. If you do not implement onRequestClose, the user can dismiss it and the application will get stuck.

@okwasniewski
Copy link
Contributor Author

okwasniewski commented May 21, 2025

@javache I've cloned the implementation for old architecture. Additionally I've added warnings and updated types. Also the PR is now marked as BREAKING

@javache
Copy link
Member

javache commented May 22, 2025

Let's update the changelog a bit to make it explicit what developers need to use if they use Modal on iOS. Otherwise looks good.

@okwasniewski
Copy link
Contributor Author

@javache Let me know if I should add something more to this description:

[IOS] [BREAKING] - Allow to interactively swipe down the modal. Implementing onRequestClose is now required so that the modal doesn't end up in a corrupted state on iOS.

@okwasniewski
Copy link
Contributor Author

Hey @javache @cipolleschi is there anything else needed to get this PR merged?

@facebook-github-bot
Copy link
Contributor

@javache has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@javache
Copy link
Member

javache commented Jun 13, 2025

Thanks for the ping here. I think we can safely make this a non-breaking change by making this controlled through an iOS-specific prop (allowSwipeDismissal) which we default to false, and we only log the new warning when that props is enabled. What do you think?

@okwasniewski okwasniewski force-pushed the fix/modal-dismiss branch 2 times, most recently from 398d064 to 7276d13 Compare June 16, 2025 14:29
@okwasniewski
Copy link
Contributor Author

Hey @javache thanks for your suggestion, I've added this as a prop. Can you re-review?

@facebook-github-bot
Copy link
Contributor

@javache has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@javache
Copy link
Member

javache commented Jun 17, 2025

Can you also send a PR for the docs? https://reactnative.dev/docs/modal

The current docs seem incorrect with the description in the PR here:

On iOS, this callback is called when a Modal is being dismissed using a drag gesture when presentationStyle is pageSheet or formSheet

According to the docs, the previous callback would've also been delivered from presentationControllerDidAttemptToDismiss:

@okwasniewski
Copy link
Contributor Author

@javache I've added PR to the docs: facebook/react-native-website#4658

I'm not sure If I understand your concern about current documentation state because before the onRequestClose would be also called on iOS but users had to update state in there to hide the modal.

With this new prop we allow users to fully swipe down the modal and afterwards we call onRequestClose so in both cases its called

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Jun 18, 2025
@facebook-github-bot
Copy link
Contributor

@javache merged this pull request in 28986a7.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @okwasniewski in 28986a7

When will my fix make it into a release? | How to file a pick request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. p: Callstack Partner: Callstack Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants