VoiceOver seems to ignore the label of a button when it is combined with other views. Let's take the following example:
swift
VStack {
Text("Title")
Button(action: increment) {
Text("My Primary Button")
}
}
.accessibilityElement(children: .combine)
I would expect VoiceOver to read "Title, My Primary Button, Button".
However it reads "Title, Button" instead, ignoring the button's label.
To make it read the button's label, you can use the following code:
swift
VStack {
Text("Title")
Button(action: increment) {
Text("My Primary Button")
}
.accessibility(removeTraits: .isButton)
}
.accessibilityElement(children: .combine)
.accessibility(addTraits: .isButton)
Now, I don't think this is really how it's supposed to work. Or am I missing something? Is this a SwiftUI "bug"?