diff --git a/WordPress/Classes/ViewRelated/Post/Publishing/PublishPostViewController.swift b/WordPress/Classes/ViewRelated/Post/Publishing/PublishPostViewController.swift index d70e0aef88b1..7d0bb2477dbf 100644 --- a/WordPress/Classes/ViewRelated/Post/Publishing/PublishPostViewController.swift +++ b/WordPress/Classes/ViewRelated/Post/Publishing/PublishPostViewController.swift @@ -51,10 +51,7 @@ final class PublishPostViewController: publishVC.onCompletion = completion // - warning: Has to be UIKit because some of the `PostSettingsView` rows rely on it. let navigationVC = UINavigationController(rootViewController: publishVC) - navigationVC.sheetPresentationController?.detents = [ - .custom(identifier: .medium, resolver: { _ in 526 }), - .large() - ] + configureSheetPresentation(of: navigationVC, from: presentingViewController) presentingViewController.present(navigationVC, animated: true) } @@ -90,10 +87,7 @@ final class PublishPostViewController: completion(result) } let navigationVC = UINavigationController(rootViewController: publishVC) - navigationVC.sheetPresentationController?.detents = [ - .custom(identifier: .medium, resolver: { _ in 526 }), - .large() - ] + configureSheetPresentation(of: navigationVC, from: presentingViewController) presentingViewController.present(navigationVC, animated: true) } @@ -121,6 +115,27 @@ final class PublishPostViewController: } } +/// Configures how the publishing sheet is presented based on the screen size. +/// +/// In compact width, the sheet opens at a partial-height detent that can be +/// dragged to full height. In regular width, it is presented as a plain form +/// sheet instead. A sheet resting at a non-large detent is not marked as +/// accessibility-modal by UIKit, which left Voice Control unable to reach any +/// of the sheet's elements when presented over the editor (CMM-2216). +private func configureSheetPresentation( + of navigationVC: UINavigationController, + from presentingViewController: UIViewController +) { + if presentingViewController.traitCollection.horizontalSizeClass == .regular { + navigationVC.modalPresentationStyle = .formSheet + } else { + navigationVC.sheetPresentationController?.detents = [ + .custom(identifier: .medium, resolver: { _ in 526 }), + .large() + ] + } +} + struct PublishPostView: View { @ObservedObject var viewModel: ViewModel var uploadsViewModel: PostMediaUploadsViewModel?