Fix: add Cancel button to photo picker on macOS when Photos library is empty#509
Open
stakeswky wants to merge 1 commit intokeepassium:masterfrom
Open
Fix: add Cancel button to photo picker on macOS when Photos library is empty#509stakeswky wants to merge 1 commit intokeepassium:masterfrom
stakeswky wants to merge 1 commit intokeepassium:masterfrom
Conversation
|
|
Author
|
I have read the CLA Document and I hereby sign the CLA |
…s empty When the Photos library is empty on macOS (Catalyst), PHPickerViewController renders no close/cancel button and ignores Esc/Cmd+Q, leaving the user unable to dismiss the picker without force-quitting the app (issue keepassium#507). Fix: after presenting the picker, inject a UIBarButtonItem(.cancel) into its navigationItem.leftBarButtonItem under #if targetEnvironment(macCatalyst). Tapping it dismisses the picker and calls the completion handler with nil, matching the existing behaviour for a cancelled pick. Fixes keepassium#507
bb9b293 to
c974e79
Compare
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.
Problem
Fixes #507.
When the macOS Photos library is empty,
PHPickerViewControllerrenders with no close/cancel button and ignoresEsc/Cmd+Q, leaving the user unable to dismiss the picker without force-quitting KeePassium.Root cause
On macOS Catalyst,
PHPickerViewControllernormally shows a Cancel button only when there is content to browse. With an empty library it shows a blank sheet with no interactive controls, and the system does not forward keyboard shortcuts to dismiss it.Fix
After presenting the picker, inject a
UIBarButtonItem(.cancel)intopicker.navigationItem.leftBarButtonIteminside a#if targetEnvironment(macCatalyst)guard. Tapping it dismisses the picker and calls the completion handler withnil, matching the existing behaviour for a cancelled pick on all other paths.The change is compile-time gated so it has zero impact on iOS builds.