Simplify and improve accessibility implementation #284
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.
Details
This simplifies and also improves support for Voice Over. Previously, we had the concept of on-screen accessibility elements, and some special off-screen accessibility elements that we used to make off-screen content focusable by Voice Over to prevent the dreaded "heading not found" issue that happens with lazy views like this and
UICollectionView
.That approach had some issues with SwiftUI views, since it made some assumptions about the off-screen accessibility element being based on a
UIView
.I rethought things a bit, and realized we could simplify. I had recently added support for doing an extended bounds layout pass, which forces off-screen views to be created and laid out for the purpose of having animations look better. We can reuse this code when Voice Over is running to ensure that nearby off-screen views can be focused. This change allows us to unify how all accessibility elements are treated, no longer needing to differentiate between off-screen and on-screen elements.
Related Issue
N/A
Motivation and Context
Fixes accessibility behavior for SwiftUI views
How Has This Been Tested
Example app
Types of changes
Checklist