Skip to content

Keep the iOS pick open when a swipe down is cancelled - #2244

Open
vicajilau wants to merge 1 commit into
mainfrom
fix/ios-partial-swipe-cancels-pick
Open

vicajilau wants to merge 1 commit into
mainfrom
fix/ios-partial-swipe-cancels-pick

Conversation

@vicajilau

Copy link
Copy Markdown
Owner

Fixes #2243

Problem

On iOS, starting to swipe the picker sheet down and letting it spring back completed pickFiles() with an empty list while the picker stayed open. The files selected afterwards were dropped.

presentationControllerWillDismiss finished the request right away, but UIKit calls it as soon as the user starts pulling the sheet down, even if the dismissal is then cancelled. finishCurrentRequest(nil) cleared result, so the later picker(_:didFinishPicking:) hit its guard let currentResult = result and returned early. Thanks to @chrisbobbe for the precise diagnosis.

presentationControllerWillDismiss was added in #2040 to fix #2021, where a very fast swipe could leave the picker stuck and fail every later pick with multiple_request, so it cannot simply be removed.

Change

presentationControllerWillDismiss now waits for the dismissal transition to end through the presented view controller's transitionCoordinator, and only finishes the request if the transition was not cancelled.

presentationControllerDidDismiss keeps finishing it as well, which is harmless since finishCurrentRequest ignores a request that is already finished.

Bumps file_picker_darwin to 2.1.4.

Testing

presentationControllerWillDismiss finished the request right away, but UIKit calls it as soon as the user starts pulling the sheet down, even if they let it spring back. The pick completed as cancelled while the picker stayed open, and the files selected afterwards were dropped because the request had already been cleared.

Wait for the dismissal transition to end and only finish the request if it was not cancelled. A completed dismissal, including the fast swipe from #2021 that may never reach presentationControllerDidDismiss, still finishes the request. Without a transition coordinator it finishes right away, as before.

Bumps file_picker_darwin to 2.1.4.

Fixes #2243

This branch has not been deployed

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

Labels

None yet

Projects

None yet

2 participants