Skip to content

Commit e184a5f

Browse files
author
User
committed
Fix: allow dismissing photo picker on macOS when Photos library is empty (#507)
On Mac Catalyst, PHPickerViewController defaults to isModalInPresentation = true, which prevents dismissal via Escape or clicking outside the sheet. When the Photos library is empty, the picker shows no cancel button, trapping the user. Set isModalInPresentation = false on Mac Catalyst so the sheet can always be dismissed interactively. Also fix swapped extension conformance labels (PHPickerViewControllerDelegate and UIAdaptivePresentationControllerDelegate were on the wrong extensions).
1 parent 4dc000d commit e184a5f

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

KeePassium/util/photo-picker/GalleryPhotoPicker.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ final class GalleryPhotoPicker: PhotoPicker {
2424

2525
picker.delegate = self
2626
picker.presentationController?.delegate = self
27+
#if targetEnvironment(macCatalyst)
28+
picker.isModalInPresentation = false
29+
#endif
2730
}
2831

2932
override internal func _pickImageInternal() {
@@ -44,7 +47,7 @@ final class GalleryPhotoPicker: PhotoPicker {
4447
}
4548
}
4649

47-
extension GalleryPhotoPicker: UIAdaptivePresentationControllerDelegate {
50+
extension GalleryPhotoPicker: PHPickerViewControllerDelegate {
4851
func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
4952
guard let result = results.first,
5053
result.itemProvider.canLoadObject(ofClass: UIImage.self)
@@ -98,7 +101,7 @@ extension GalleryPhotoPicker: UIAdaptivePresentationControllerDelegate {
98101
}
99102
}
100103

101-
extension GalleryPhotoPicker: PHPickerViewControllerDelegate {
104+
extension GalleryPhotoPicker: UIAdaptivePresentationControllerDelegate {
102105
func presentationControllerDidDismiss(_ presentationController: UIPresentationController) {
103106
_completion?(.success(nil))
104107
}

0 commit comments

Comments
 (0)