-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Adding pager, scrollview, viewgroup, webview, drawer roles #34477
Changes from all commits
343279e
b0c8d91
82b309a
1d246f1
a48d4f0
c8084c5
c9e5d7a
a38d81c
569cd1c
d2bddb2
d267860
578e29c
83960b7
d7bcd28
805cee4
a4ae90c
2d73468
42667ff
58c2fc4
bd5f11e
1b69235
d460d09
45235d3
f694992
0f07b2e
fc60bd6
1955558
2504fbd
a87b298
d5690b6
9764c48
ab893d9
9801320
9f89049
e1c2878
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,7 @@ private void scheduleAccessibilityEventSender(View host) { | |
public enum AccessibilityRole { | ||
NONE, | ||
BUTTON, | ||
DROPDOWNLIST, | ||
TOGGLEBUTTON, | ||
LINK, | ||
SEARCH, | ||
|
@@ -123,20 +124,30 @@ public enum AccessibilityRole { | |
TIMER, | ||
LIST, | ||
GRID, | ||
PAGER, | ||
SCROLLVIEW, | ||
HORIZONTALSCROLLVIEW, | ||
VIEWGROUP, | ||
WEBVIEW, | ||
DRAWERLAYOUT, | ||
SLIDINGDRAWER, | ||
ICONMENU, | ||
TOOLBAR; | ||
|
||
public static String getValue(AccessibilityRole role) { | ||
switch (role) { | ||
case BUTTON: | ||
return "android.widget.Button"; | ||
case DROPDOWNLIST: | ||
return "android.widget.Spinner"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I searched the source code of all these libraries and I found one library using the native Component android.widget.Spinner. The library is react-native-picker/picker. I would keep the role. |
||
case TOGGLEBUTTON: | ||
return "android.widget.ToggleButton"; | ||
case SEARCH: | ||
return "android.widget.EditText"; | ||
case IMAGE: | ||
return "android.widget.ImageView"; | ||
case IMAGEBUTTON: | ||
return "android.widget.ImageButon"; | ||
return "android.widget.ImageButton"; | ||
case KEYBOARDKEY: | ||
return "android.inputmethodservice.Keyboard$Key"; | ||
case TEXT: | ||
|
@@ -155,6 +166,22 @@ public static String getValue(AccessibilityRole role) { | |
return "android.widget.AbsListView"; | ||
case GRID: | ||
return "android.widget.GridView"; | ||
case SCROLLVIEW: | ||
return "android.widget.ScrollView"; | ||
case HORIZONTALSCROLLVIEW: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think SCROLLVIEW and HORIZONTALSCROLLVIEW should be returning their own classes. See the talkback source here: It's only if they have collectionInfo that they fall back to the Grid or List role, and that can happen internally to Talkback, so we don't need to worry about that logic. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @blavalla Thanks. I made the changes and also added an example of ScrollView to the Accessibility Example. I reviewed the react-native implementation of these accessibility functionalities, comparing them with the original Android implementation in their respective widgets. I tested the TalkBack functionalities and I did not detect any issue. |
||
return "android.widget.HorizontalScrollView"; | ||
case PAGER: | ||
return "androidx.viewpager.widget.ViewPager"; | ||
case DRAWERLAYOUT: | ||
return "androidx.drawerlayout.widget.DrawerLayout"; | ||
case SLIDINGDRAWER: | ||
return "android.widget.SlidingDrawer"; | ||
case ICONMENU: | ||
return "com.android.internal.view.menu.IconMenuView"; | ||
case VIEWGROUP: | ||
return "android.view.ViewGroup"; | ||
case WEBVIEW: | ||
return "android.webkit.WebView"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://github.com/react-native-webview/react-native-webview/search?q=android.webkit.WebView |
||
case NONE: | ||
case LINK: | ||
case SUMMARY: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the intent was for these to map roughly to ARIA roles? https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles
Are there existing cases where we have custom roles for things like this? Some of these seem like they don't quite fit with the theme of specifying a semantic role (e.g. I cannot imagine there ever being a "drawerlayout" or "webview" ARIA role).
cc @necolas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NickGerleman , @necolas
This PR isn't related to aria, so there may be two different issues in this space. This was a PR that resolved the issue of not all native Android roles being supported in RN, which means components built in RN have different behavior than if those components were built natively.
Aria has no concepts that map to many of these (and "webview" specifically wouldn't even make sense for a web-spec like aria), but RN components need these roles if we want them to work like their native implementations.
Whether we want to support native-specific functionality like this comes down to a pretty core question about the RN framework itself, which is whether it's trying to be a framework that bridges the gap between iOS, Android, and other native platforms, or if it's trying to bring web-specific paradigms (such as aria) to those native platforms.
If it's meant to bring web paradigms to those platforms, we'll basically need to rethink the entire set of accessibility APIs and start from scratch, as they are currently almost entirely focused on the native-specific approaches that accessibility takes. The native approach to accessibility is often considerably different from the approach taken on the web, mainly due to the differences in the way accessibility services themselves are built on native platforms.
Things like custom actions, hints, magic tap, certain roles/traits, etc. that are native-specific would need to be left out. And things like tab-index, landmarks, and other web-specific features would have to be implemented from scratch.
The end result of this is that apps built with React Native would "feel" more like the web to users of assistive technology, and not feel like native apps. We've already heard this feedback about pretty basic roles like "radio group", which confused some users as they didn't expect it to be in a native application (@alextait1 has more details on that feedback).
Overall I think this is a decision the RN team needs to make, and provide clarity on, as right now the accessibility API is in a pretty weird state, with some web-specific features attempted to be included in (and not working the way they do on the web), some web-specific features left out (when they could work on native), some native-specific features left out (that have no web equivalents), and some native-specifics features includes with slightly different APIs, when there is a similar enough web equivalent to map to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
role
prop is typed separately and equivalent values are then mapped toaccessibilityRole
values, so at a glance this looks ok as it's adding values to the latter.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, if we have separated out
role
andaccessibilityRole
, then it seems like this could be a clean separation, whereaccessibilityRole
can have roles that might be platform specific, divergent from ARIA. As long as any mapping still works correctly, I think this change should make sense then.It does seem like we have a bit of a messy experience for developers trying to reason about what a role does, if it works, what platforms it works on, etc. If platforms do really have specific needs not represented in a common spec (and it seems like they still do), I am all in favor of letting RN expose them.
It might be worth leaving documentation as to what roles are platform specific. In code/on the website (@fabriziobertoglio1987 I'm guessing this change will be reflected in a documentation update?).
The TypeScript typings adjacent in
ViewAccessibility.d.ts
(which we should update, either as part of this change or a followup), have a split between platforms for individual properties, but not role. Maybe that can be split, so that users get some hint? Though platform-specific typechecking is a more general open problem (FYI @acoates-ms who has cared about that in the past).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also FYI to @lunaleaps that it looks like
role
and the ARIA types are missing from the TS declarations. We should update those over, if we are not immediately moving that file to TS generation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NickGerleman this notifications did not go in my inbox for some reason. Sorry. The documentation is available at https://github.com/facebook/react-native-website/pull/3287/files