accessibilityElements excludes the unlisted subviews – How to Fix?

I have a parent view containing 10 subviews. To control the VoiceOver navigation order, I set only a few elements in accessibilityElements. However, the remaining elements are not being focused or are completely inaccessible.

Is this the expected behavior? If I only specify a subset of elements in accessibilityElements, does it exclude the rest? What’s the best way to ensure all elements remain accessible while customising the order?

Answered by Frameworks Engineer in 831002022

Yes, when you set the accessibilityElements property on a view, only the elements included will be accessible to features like VoiceOver, Switch Control, Voice Control, etc.

You're right, however, that you can use this property to manually specify element ordering. But you also must remember to include all of the elements if that is your desire.

Before you override and set the accessibilityElements property, you can use this same property to poll what all the elements are, and then order them this way as you wish. Does trying something like this help?

Accepted Answer

Yes, when you set the accessibilityElements property on a view, only the elements included will be accessible to features like VoiceOver, Switch Control, Voice Control, etc.

You're right, however, that you can use this property to manually specify element ordering. But you also must remember to include all of the elements if that is your desire.

Before you override and set the accessibilityElements property, you can use this same property to poll what all the elements are, and then order them this way as you wish. Does trying something like this help?

@Frameworks Engineer Thank you! I’ve already implemented a solution similar to what you suggested. I filtered the desired elements from the existing array, reordered them, and then appended them to the default order elements.

accessibilityElements excludes the unlisted subviews – How to Fix?
 
 
Q