-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
byRole queries don't find element that don't have an explicitly set accessibilityRole prop #1130
Comments
This is a questions whether we want to emulate that behavior or should React Native actually set these roles by itself. I wonder why React Native is not supporting more of ARIA roles? It even misses things like |
There is a valid point of if RN should support more roles. However, if you look at RTL, they do support by themselves both the raw dom element and custom So at least, we should support |
Regarding getting implicit roles there is another relevant public API: Looks like it's responsible for calculating both explicit and implicit roles for given element: https://github.com/testing-library/dom-testing-library/blob/a9a8cf26992ff0f6b4257b7300939f461d04440d/src/role-helpers.js#L155 |
I think we also need to think whether to support some ARIA roles that are important but not present in RN |
Do we know which implicit roles we want to support for which components? Initially we could start with:
By default Implicit roles would be used by |
I think we could take some inspiration from aria role, which is more exhaustive than If we follow their logic:
I strongly believe that if an element is not read with a specific role by screen-readers, then we shouldn't determine an implicit role. |
I think we need to build some playground repos for native, so that we have easier job when examining these roles. For native we could build a sample Expo app and the test it using VoiceOver on iOS and TalkBack on Android. If I understand correctly these screen readers should announce roles for the elements. It also seems that there are difference between RN Accessiblity Roles, ARIA roles, UIKit Accessibility Traits and Android where I could not find anything in the API resembling roles. E.g. ARIA does not have a role for static text, iOS has We should follow recent RN activity facebook/react-native#34538, and base most of our decisions on ARIA roles, but also taking into account how screen readers act on iOS/Android.
This RN PR has mapping between ARIA and RN roles. |
Not sure how reliable is ESLint A11y plugin, but there are some of interesting rules:
If we treat this as valid, we should assume that touchables (& pressable) do not have default role, neither Snapshot of:
is
Default value of
Default value of
|
BTW There seems to be some accessibility stuff that might help us with assumptions in RNTester app: https://github.com/facebook/react-native/blob/e8739e962de3398bc7e42675b1d87ab35993f705/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js App itself is located here: https://github.com/facebook/react-native/blob/main/packages/rn-tester/README.md |
In order to have more concrete information about iOS/Android behaviour, I've stared doing experiments how different a11y props combinations affects behaviour of assistive tech on iOS and Android. I share initial findings in newly created wiki page. If you have time, please contribute your research for other component types ( |
I've checked for Pressable and Image on ios using VoiceOver:
|
Describe the bug
react-native
built-in elements are not queriable withbyRole
queries if you don't set theaccessibilityRole
prop.Expected behaviour
byRole
queries should be able to match some elements withoutaccessibilityRole
.We however need to be conscious of what roles should be used to match what elements. My suggestion is checking each element with a voice-over and see what matches:
<Pressable />
bebutton
by default?<TextInput />
will readInput
on ios voiceover, but that is not anAccessibilityRole
as exported byreact-native
.We might need to think about types. The point raised in #1127 (comment) that suggests using
TextMatch
for the role will make it harder to discover those cases.Steps to Reproduce
Versions
Latest.
The text was updated successfully, but these errors were encountered: