fix(iOS): onNativeDismissCancelled called too early during modal dismissal #2129
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Currently, on iOS,
onNativeDismissCancelled
is being called while the user begins to drag down a modal (which calls the callback function of theusePreventRemove
hook, ifpreventRemove
istrue
).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.This PR adjusts this to the more ideal behavior.
Changes
Move the call of
notifyDismissCancelled
frompresentationControllerShouldDismiss
topresentationControllerDidAttemptToDismiss
- which "Notifies the delegate that a user-initiated attempt to dismiss a view was prevented", and has the same platform avalibality aspresentationControllerShouldDismiss
.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