Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement interactive dismiss for iOS modals #38641

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jacobp100
Copy link
Contributor

Summary:

Currently the swipe-to-dismiss gesture for iOS doesn't work well - it applies friction so you can't pull it down more than a certain amount. The intention for this - from Apple - was if you're editing a form, and you didn't want to accidentally dismiss it. When the user does this gesture, it should be followed by an alert asking them if they wanted to save or cancel

When you're not editing a form, you don't want this friction applied, so the modal can be swiped all the way off the screen. That's what this PR implements via the opt-in prop preventNativeDismiss (=true). The name comes from react-native-screens

This is opt-in and defaults to true (the current behaviour), so there's no breaking changes

See video below

Changelog:

[IOS] [ADDED] - Added preventNativeDismiss prop to modal to opt-in to drag-to-dismiss gestures for modals

Test Plan:

RN Tester

Simulator.Screen.Recording.-.iPhone.SE.3rd.generation.-.2023-07-26.at.17.22.33.mp4

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 26, 2023
const onDismiss = () => {
setVisible(false);
if (action === 'onDismiss') {
if (action === 'On Dismiss') {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm pretty sure these were always broken. I've fixed them anyway

@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jul 26, 2023
@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,889,892 +152
android hermes armeabi-v7a 7,940,376 +107
android hermes x86 9,287,679 +54
android hermes x86_64 9,191,362 -96
android jsc arm64-v8a 9,479,825 +160
android jsc armeabi-v7a 8,422,870 +107
android jsc x86 9,463,293 +45
android jsc x86_64 9,780,065 -93

Base commit: 3c6dbec
Branch: main

@erquhart
Copy link

erquhart commented Oct 5, 2023

Thanks so much for opening this @jacobp100!! @NickGerleman @philIip this has been needed for so so long, any chance of moving it forward?

@erquhart
Copy link

erquhart commented Oct 15, 2023

@NickGerleman apologies for randomly pinging you, just not sure how to get eyes on this and you seem pretty active. This PR is very small and a slam dunk - we cannot pull down on modals to close them in iOS and users expect it. This fixes that.

Any chance of a merge?

The conflict looks to be limited to the example file only.

Copy link

This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Apr 13, 2024
@erquhart
Copy link

Still needed.

@github-actions github-actions bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Apr 16, 2024
@jacobp100
Copy link
Contributor Author

image

@erquhart
Copy link

@philIip 🙏

@goguda
Copy link

goguda commented Nov 4, 2024

Would love for this to get merged as well

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. 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.

5 participants