Skip to content
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

Closed
wants to merge 35 commits into from

Conversation

fabOnReact
Copy link
Contributor

@fabOnReact fabOnReact commented Aug 23, 2022

Summary

Relevant #30839 (comment)
fixes #30839
Documentation facebook/react-native-website#3287

Changelog

[Android] [Fixed] - Adding pager, scrollview, viewgroup, webview, drawer roles

Test Plan

Android

iOS #34477 (comment)

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 23, 2022
@analysis-bot
Copy link

analysis-bot commented Aug 23, 2022

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 7,638,272 +1,632
android hermes armeabi-v7a 7,050,268 +1,635
android hermes x86 7,940,244 +1,637
android hermes x86_64 7,912,264 +1,624
android jsc arm64-v8a 9,514,568 +1,641
android jsc armeabi-v7a 8,289,855 +1,633
android jsc x86 9,454,116 +1,633
android jsc x86_64 10,045,353 +1,635

Base commit: 12e5842
Branch: main

@analysis-bot
Copy link

analysis-bot commented Aug 23, 2022

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: 12e5842
Branch: main

@fabOnReact fabOnReact changed the title TalkBack custom and standard roles 🚧 TalkBack custom and standard roles 🚧 Aug 23, 2022
@fabOnReact
Copy link
Contributor Author

fabOnReact commented Aug 23, 2022

  • DrawerLayoutAndroid - trigger announcement when opening the drawer (link)

@fabOnReact
Copy link
Contributor Author

fabOnReact commented Aug 23, 2022

@fabOnReact
Copy link
Contributor Author

fabOnReact commented Aug 23, 2022

@fabOnReact
Copy link
Contributor Author

fabOnReact commented Aug 24, 2022

TalkBack announces the Toast text without accessibilityRole

The logic for the Toast TalkBack announcement is triggered here https://github.com/aosp-mirror/platform_frameworks_base/blob/e648d3cb91f9a0156c729ca18ec27e71f59f9ce2/core/java/android/widget/Toast.java#L617. The announcement is triggered manually without using AccessibilityDelegate. No changes or role are required to announce Toast.

2022-08-24.16-25-46.mp4

1) Remove toast AccessibilityRole facebook#34477 (comment)
2) Adding ScrollView AccessibilityRole
@fabOnReact
Copy link
Contributor Author

ScrollView announces in/out of ScrollView

2022-08-24.17-36-05.mp4

@fabOnReact fabOnReact changed the title 🚧 TalkBack custom and standard roles 🚧 TalkBack custom and standard roles Aug 24, 2022
@fabOnReact fabOnReact changed the title TalkBack custom and standard roles Android TalkBack custom and standard roles Aug 24, 2022
@fabOnReact fabOnReact marked this pull request as ready for review August 31, 2022 13:11
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Aug 31, 2022
@@ -154,7 +165,21 @@ public static String getValue(AccessibilityRole role) {
case LIST:
return "android.widget.AbsListView";
case GRID:
case SCROLLVIEW:
case HORIZONTALSCROLLVIEW:
Copy link
Contributor

Choose a reason for hiding this comment

The 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:
https://github.com/google/talkback/blob/f5d564fdc915a74d8cde4868608f307de9ccf957/utils/src/main/java/com/google/android/accessibility/utils/Role.java#L341-L347

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Comment on lines 75 to 90
<string
name="scrollview_description"
translatable="false"
>Scroll View</string>
<string
name="horizontalscrollview_description"
translatable="false"
>Horizontal Scroll View</string>
<string
name="slidingdrawer_description"
translatable="false"
>Sliding Drawer</string>
<string
name="iconmenu_description"
translatable="false"
>Icon Menu</string>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's any value in adding strings for these roles unless Talkback does this itself. Some roles are purely functional and don't have different announcements upon focus. A user may get confused when they hear "Scroll View" since they aren't used to hearing these announcements in other native apps not built with React Native.

If Talkback does add these announcements though, feel free to keep these, but I couldn't find them referenced anywhere in Talkback's source.

And yeah, I realize this is a problem with existing roles added by others, but many of those are web-based, or ios-based roles that don't have any behavior defined by Talkback at all, so we aren't sure that it should do for those.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blavalla Thanks a lot. I reviewed the TalkBack implementation, and I made the changes requested.

@fabOnReact fabOnReact marked this pull request as draft September 2, 2022 08:39
@fabOnReact
Copy link
Contributor Author

roles scrollview and grid

2022-09-02.17-15-55.mp4

DrawerLayoutAndroid with or without drawerlayout role

2022-09-02.17-41-40.mp4

@fabOnReact fabOnReact marked this pull request as ready for review September 6, 2022 13:26
@fabOnReact fabOnReact changed the title Android TalkBack custom and standard roles additional android TalkBack roles Sep 7, 2022
@fabOnReact fabOnReact changed the title additional android TalkBack roles adding pager, scrollview, viewgroup, webview, drawer roles Sep 7, 2022
@fabOnReact fabOnReact changed the title adding pager, scrollview, viewgroup, webview, drawer roles Adding pager, scrollview, viewgroup, webview, drawer roles Sep 7, 2022
Copy link
Contributor

@blavalla blavalla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@facebook-github-bot
Copy link
Contributor

@blavalla has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Comment on lines +48 to +56
| 'grid'
| 'pager'
| 'scrollview'
| 'horizontalscrollview'
| 'viewgroup'
| 'webview'
| 'drawerlayout'
| 'slidingdrawer'
| 'iconmenu';
Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Contributor

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 to accessibilityRole values, so at a glance this looks ok as it's adding values to the latter.

Copy link
Contributor

@NickGerleman NickGerleman Sep 29, 2022

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 and accessibilityRole, then it seems like this could be a clean separation, where accessibilityRole 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).

Copy link
Contributor

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.

Copy link
Contributor Author

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

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @fabriziobertoglio1987 in 55c0df4.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label Nov 8, 2022
@github-actions
Copy link

github-actions bot commented Jan 9, 2023

Warnings
⚠️

Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js#L11 - Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js line 11 – Requires should be sorted alphabetically (lint/sort-imports)

Generated by 🚫 dangerJS against e1c2878

OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this pull request May 22, 2023
…34477)

Summary:
- adds missing roles
- adds custom roles that don't exist in TalkBack (see the [compositor.json][10] and [string.xml][11] files).
- fixes [issues with Drawer][12]
- fixes issues with ScrollView missing roles
- seek control already exist as adjustable facebook@d460d09

Relevant facebook#30839 (comment)
fixes facebook#30839

## Changelog

[Android] [Fixed]  - Adding pager, scrollview, viewgroup, webview, drawer roles

Pull Request resolved: facebook#34477

Test Plan:
Android
- Drawer Layout and ScrollView (02/09/22) facebook#34477 (comment)
- sliding drawer, drawer layout, icon menu facebook#34477 (comment)
- Horizontal and Vertical ScrollView facebook#34477 (comment)
- Toast facebook#34477 (comment)
- CheckedTextView facebook#34477 (comment)
- Spinner (dropdownlist) facebook#34477 (comment)
- EditText facebook#34477 (comment)
- WebView facebook#34477 (comment)
- Testing chime_up and chime_down sound feedback in Scrollable facebook#34477 (comment)

iOS facebook#34477 (comment)

[10]: https://github.com/google/talkback/blob/771de7cdbf55b6adb4ca4c64c27a52584f2337cc/compositor/src/main/res/raw/compositor.json#L1082-L1108
[11]: https://github.com/google/talkback/blob/771de7cdbf55b6adb4ca4c64c27a52584f2337cc/compositor/src/main/res/values/strings.xml#L223
[12]: facebook#34477 (comment)

Reviewed By: NickGerleman

Differential Revision: D39894307

Pulled By: blavalla

fbshipit-source-id: 4a8da78bae485ead0523689631d88d1031a07b74
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accessibility CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Not all Standard Roles/Traits supported
7 participants