VoiceOver errantly focuses a text field on the presenting view controller following a custom modal presentation

Originator:eric.horacek
Number:rdar://FB8982283 Date Originated:1/26/2020
Status:Open Resolved:No
Product:Accessibility Product Version:14.3
Classification:Incorrect/Unexpected Behavior Reproducible:Yes
 
We have a suite of custom in-house modal presentations styles that use the UIKit UIPresentationController APIs. We've noticed a VoiceOver bug with our modal presentations: if you activate a text field and then trigger one of our custom modal presentations, the text field underneath the modal steals VoiceOver focus when the modal presentation has completed. This issue only occurs with our custom modal presentations—the same issue does not reproduce with the system presentation style.

In the attached example project, you can trigger this behavior by focusing the text field, moving the focus to the "show custom modal" button, and then triggering the button. This will result in the focus first moving to the custom modal, and then errantly moving back to the previously focused text field. It is expected that focus stays on the presented modal view controller. You can find attached a video of this behavior as well.

If you perform the same steps but trigger the "show system modal" instead, you will notice that the aforementioned behavior does not occur.

We have only noticed this behavior when the presenting view controller has UICollectionView content. It doesn't appear to reproduce when the presenting view controller has a UIStackView content.

Tested on Xcode 12.3/iOS 14.3.

Comments

We were able to fix this by adding the following logic to our UIPresentationController subclass's presentationTransitionWillBegin method:

if UIAccessibility.isVoiceOverRunning { presentingViewController.view.endEditing(true) }

By eric.horacek at Jan. 27, 2021, 5:01 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!