Post

Replies

Boosts

Views

Activity

Reply to iOS:How to code accessibility, that if user tap on the parent view then whole view should speak, if user tap the child view so only it should be speak
When you use accessibilityElement(children: .combine), and there is a Button in the children, then the new combined group will inherit the isButton trait (in other words, the group becomes a Button). The VoiceOver system automatically converts the action to the default activate accessibility action and the Button's label is no longer announced (however, you explicitly set an accessibilityLabel on the Button which is what is used). That's why you see this behavior; I do not know if this is a bug, just what I have observed. You have also redeclared Button as an accessible element which removes its previous label "Show details", and it instead is using the "This is show detail" label that you told it to use for accessibility. Wrt Voiceover dropping the Button's label unless an accessibilityLabel is explicitly applied; my theory is that VoiceOver assumes the Button's siblings accessibilityLabels will provide the context necessary to activate the Button group. However, as you can imagine this could lead to unexpected consequences. I don't think it's possible to achieve your requirement because by using combine, the group becomes the leaf in the accessibility tree which encompasses the Button, thus the Button cannot also be a leaf. If you try using contain, then each element will be a leaf and therefore not in a group and the button will remain tappable on its own.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’23
Reply to iOS:How to code accessibility, that if user tap on the parent view then whole view should speak, if user tap the child view so only it should be speak
When you use accessibilityElement(children: .combine), and there is a Button in the children, then the new combined group will inherit the isButton trait (in other words, the group becomes a Button). The VoiceOver system automatically converts the action to the default activate accessibility action and the Button's label is no longer announced (however, you explicitly set an accessibilityLabel on the Button which is what is used). That's why you see this behavior; I do not know if this is a bug, just what I have observed. You have also redeclared Button as an accessible element which removes its previous label "Show details", and it instead is using the "This is show detail" label that you told it to use for accessibility. Wrt Voiceover dropping the Button's label unless an accessibilityLabel is explicitly applied; my theory is that VoiceOver assumes the Button's siblings accessibilityLabels will provide the context necessary to activate the Button group. However, as you can imagine this could lead to unexpected consequences. I don't think it's possible to achieve your requirement because by using combine, the group becomes the leaf in the accessibility tree which encompasses the Button, thus the Button cannot also be a leaf. If you try using contain, then each element will be a leaf and therefore not in a group and the button will remain tappable on its own.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’23