🐛 Fix iOS picker dismiss issue when swiping before full load#412
Open
mihf05 wants to merge 1 commit intovinceglb:mainfrom
Open
🐛 Fix iOS picker dismiss issue when swiping before full load#412mihf05 wants to merge 1 commit intovinceglb:mainfrom
mihf05 wants to merge 1 commit intovinceglb:mainfrom
Conversation
Fixes vinceglb#138 - No event generated on iOS when dismissing selection dialog **Problem:** - When users quickly dismissed iOS file/photo pickers by swiping down before the picker was fully loaded/animated, no dismiss event was generated - This affected both UIDocumentPickerViewController and PHPickerViewController - Only normal cancellation (via Cancel button or full sheet dismissal) worked properly **Root Cause:** - iOS handles early dismissals differently than normal cancellations - Early dismissals only trigger presentationControllerDidDismiss, not the standard picker delegate methods - Original implementation didn't implement UIAdaptivePresentationControllerDelegateProtocol **Solution:** 1. **Enhanced DocumentPickerDelegate:** - Added UIAdaptivePresentationControllerDelegateProtocol implementation - Implemented presentationControllerDidDismiss() to catch early dismissals - Added hasFinished flag to prevent race conditions between delegate methods 2. **Enhanced PhPickerDelegate:** - Added UIAdaptivePresentationControllerDelegateProtocol implementation - Consolidated dismiss handling into single delegate - Added hasFinished flag for race condition prevention 3. **Removed PhPickerDismissDelegate:** - Eliminated separate dismiss delegate to prevent race conditions - Consolidated functionality into PhPickerDelegate for cleaner architecture 4. **Updated FileKit.ios.kt:** - Assigned delegates as both picker delegates and presentation controller delegates - Applied changes to document picker, file saver, and photo picker scenarios - Removed references to deleted PhPickerDismissDelegate **Files Changed:** - Modified: DocumentPickerDelegate.kt - Added presentation controller delegate protocol - Modified: PhPickerDelegate.kt - Added presentation controller delegate and consolidated functionality - Deleted: PhPickerDismissDelegate.kt - Consolidated into PhPickerDelegate - Modified: FileKit.ios.kt - Updated delegate assignments and removed references to deleted class **Testing:** - iOS compilation verified successfully - No syntax errors in modified files - Maintains backward compatibility **Result:** All dismissal scenarios now properly trigger the dismiss callback, including early swipe-to-dismiss gestures.
vinceglb
requested changes
Nov 28, 2025
Owner
vinceglb
left a comment
There was a problem hiding this comment.
Sorry for the delay. Today I tried your fix but I still have the same behavior: if I dismiss the photo picker before full display, I don't get any result.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #138 - No event generated on iOS when dismissing selection dialog
Problem
When users quickly dismissed iOS file/photo pickers by swiping down before the picker was fully loaded/animated, no dismiss event was generated. This affected both
UIDocumentPickerViewControllerandPHPickerViewController. Only normal cancellation (via Cancel button or full sheet dismissal) worked properly.Root Cause
presentationControllerDidDismiss, not the standard picker delegate methodsUIAdaptivePresentationControllerDelegateProtocolSolution
1. Enhanced DocumentPickerDelegate
UIAdaptivePresentationControllerDelegateProtocolimplementationpresentationControllerDidDismiss()to catch early dismissalshasFinishedflag to prevent race conditions between delegate methods2. Enhanced PhPickerDelegate
UIAdaptivePresentationControllerDelegateProtocolimplementationhasFinishedflag for race condition prevention3. Removed PhPickerDismissDelegate
PhPickerDelegatefor cleaner architecture4. Updated FileKit.ios.kt
PhPickerDismissDelegateFiles Changed
DocumentPickerDelegate.kt- Added presentation controller delegate protocolPhPickerDelegate.kt- Added presentation controller delegate and consolidated functionalityPhPickerDismissDelegate.kt- Consolidated into PhPickerDelegateFileKit.ios.kt- Updated delegate assignments and removed references to deleted classWhy PhPickerDismissDelegate was Deleted
The
PhPickerDismissDelegate.ktfile was removed because:Testing
Result
All dismissal scenarios now properly trigger the dismiss callback, including early swipe-to-dismiss gestures.
Type of Change
Platform Impact
Checklist
Fixes #138