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

fix(iOS): onNativeDismissCancelled called too early during modal dismissal #2129

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

zetavg
Copy link
Contributor

@zetavg zetavg commented May 12, 2024

Description

Currently, on iOS, onNativeDismissCancelled is being called while the user begins to drag down a modal (which calls the callback function of the usePreventRemove hook, if preventRemove is true).

This is not a common behavior of iOS apps and can sometimes be annoying: the callback will be triggered while the user is scrolling around a ScrollView in the modal and has hit the top, which is interrupting.

Ideal Before After
Ideal Before After
The event fires when the user releses the drag. If the user did not intend to dismiss the modal (the user did not drag it down far enough or dragged it back to its original position before release), the event will not fire. The event fires as soon as the modal is dragged down, regardless of whether the user intends to dismiss the modal or not. (In this case, the user just wants to scroll to the top.) Same as "Ideal".

This PR adjusts this to the more ideal behavior.

Changes

Move the call of notifyDismissCancelled from presentationControllerShouldDismiss to presentationControllerDidAttemptToDismiss - which "Notifies the delegate that a user-initiated attempt to dismiss a view was prevented", and has the same platform avalibality as presentationControllerShouldDismiss.

Test code and steps to reproduce

Use the new "Prevent Remove" example:

Full test recordings

Modal

Full.Test.-.Modal.-.05.mp4

Normal Screen (this should not be affected since I believe that preventing going back from a normal screen is not handled here)

Full.Test.-.Screen.-.05.mp4

Checklist

@zetavg
Copy link
Contributor Author

zetavg commented May 12, 2024

Note: both #1959 and this PR can achieve #1950. But I think this should be the default behavior of onNativeDismissCancelled and usePreventRemove - firing the callback when the user releases the drag.

@kkafar kkafar self-requested a review May 15, 2024 11:51
@kkafar
Copy link
Member

kkafar commented May 15, 2024

Hi @zetavg, thanks for preparing these changes 🎉. I took a glance & these changes look good, however I'll need to find time to test this! Will get back you once I do.

@kkafar kkafar added the Feature impl PR with feature implementation label May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature impl PR with feature implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants