Not all Standard Roles/Traits supported
See original GitHub issueRequires API Proposal
This issue may require a new API, or changes to an existing API. An API proposal should be added and discussed before proceeding with implementation. The API proposal can be added in the comments of this issue or linked as a separate issue.
Description
On Android, not all roles are currently supported, and on iOS not all traits are currently supported.
Not all Android roles map cleanly to an iOS trait, and vice versa, so we may want to consider marking some of these in the documentation as iOS-only or Android-only.
The list of missing roles/traits is below under iOS and Android Details.
Furthermore, while some components allow you to technically set a role with the accessibilityRole
prop, these are not always applied. <Button>, <Picker>, <Slider>, <TextInput>, <Switch>, and <AndroidProgressBar> have this issue. While this may have been an intentional choice, it feels broken from an API perspective to allow what looks like a role override prop to exist, but have it do nothing. If we allow this prop, it should correctly override the default role of the component.
React Native version:
v0.63
#Android Details The following Android roles are not currently supported:
- checked_text_view
- drop_down_list
- edit_text
- grid
- list
- pager
- seek_control (slider)
- toggle_button - #31419
- view_group
- web_view
- drawer_layout
- sliding_drawer
- icon_menu
- toast
- date_picker
- date_picker_dialog
- time_picker
- time_picker_dialog
- number_picker
- scroll_view
- horizontal_scroll_view
Out of this list many of these roles are rarely used, but many are also quite common (such as list, edit_text, toast, and seek_control).
List of all roles here: https://github.com/google/talkback/blob/master/utils/src/main/java/Role.java
iOS Details:: The following iOS traits are not currently supported, but they don’t really make sense to be added to the “accessibilityRole” prop, as they are more metadata about the element than specific element types. We may want to consider adding specific APIs for these, or adding some new API for accessibility metadata like this.
- causesPageTurn
- startsMediaSession
- allowsDirectInteraction
- playsSound
- updatesFrequently
The list of all iOS traits can he found here: https://developer.apple.com/documentation/objectivec/nsobject/uiaccessibility/accessibility_traits
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:11 (4 by maintainers)
Top GitHub Comments
There isn’t really any equivalent on Android (at least with Talkback). Talkback basically treats elements without a defined role as “text” in this regard, but there is no special functionality related to these elements. Regardless of the elements role (button, checkbox, etc.), the basic text functionality of changing the readback granularity between letters, words, and all-at-once is available.
Androids TextView class does have a lot of accessibility specific behavior around things like text selection, copy/paste, and cursor control, but all of this is handled in the TextView class in Android (outside of Talkback), and can’t be emulated by simply switching roles. Under the hood, react Native’s <Text> component extends Androids AppCompatTextView class, which in turn extends TextView, giving all of this accessibility-specific functionality. If you are looking for the proper way to represent text on Android, I’d say using RN’s <Text> is your best bet.
Talkback doesn’t have an equivalent of iOS’s “StaticText” trait, which is what this role maps to on that platform, so there is no expected behavior when using this role on Android.