-
Notifications
You must be signed in to change notification settings - Fork 128
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
RFC: Accessibility APIs #410
Conversation
65b1821
to
8e62cdd
Compare
8e62cdd
to
fd64774
Compare
Landmark roles are already accounted for in ARIA as values of the |
Generally speaking I'm very much in favor of this idea! ARIA seems naturally suited to react-native for a number of reasons:
I think snapping to aria does raise a few questions, though:
|
Being pragmatic it's the latter for now. Although I think having specs for implementations is part of the appeal (as it is for Yoga to implement flexbox), and at worst the specs can be used to understand how the RN implementation differs from others.
That is the open question at the end of the proposal. In the short term these props are needed. If other changes to RN are made in the future we might be able to separate behavior from views, including platform-specific functionality like accessibility actions. const ref = useAccessibilityActions({
onAccessibilityAction,
accessibilityActions
});
return <View ref={ref} />; Problems like this lead me to ask: 1) Can |
I hadn't realized landmarks in ARIA are implemented as values for role, thanks for pointing it out. That's the main reason I went with an implementation through a new prop, but we'll be able to add these values and move the logic over to accessibilityRole fairly easily. |
I'm also in favor of this proposal 🙂 my questions are:
|
Good to know you already need these props too. All the ARIA properties are supported in RN for Web and if we were to adopt the ARIA APIs they could be added to RN. I can include them in the proposal. There are even more ARIA attributes for defining tabular data, etc...do you also have a need for those yet?
The (This proposal is an attempt to provide guiding principles - ARIA - for defining new a11y props so we can limit further proliferation of adhoc prop additions.)
Yes I think we should support both since that is the attribute's purpose in ARIA too. But it depends on the constraints of various native platforms and requires input from Android/iOS experts. |
While I like the general idea of having a more unified API between native and web, there are some pretty big differences that would need to be taken into account that would ultimately make this new API not quite close enough to web to be a direct mapping, but not quite close enough to native to also be a direct mapping, basically ending up as a strange hybrid of the two (which doesn't even take into account the large differences between how iOS and Android handle some of the basics like focus). To give some context, web accessibility has a very declarative API, where you declare various attributes on DOM elements, and then allow the assistive tech (AT) to parse those out and determine its behavior. On native, while many properties are declarative (traits, labels, etc.), there is also the concept of directly interfacing with the AT itself to control it. Things such as sending accessibility events on Android, creating custom rotors on iOS, and making manual announcements (both platforms), all rely on the app directly telling the AT to do something, and it responding to this. This difference is likely due to the significantly simpler interaction models that mobile ATs have, where a user may only have a few gestures they can use to control them, so much of the advanced control relies on the apps themselves to add specific actions and features for the user. As for the details of this proposal, I have a few items that I think need to be thought through in more depth. I'll outline them by phase below: Phase 1
Phase 2
Phase 3
So in conclusion, I really like the idea here, but I think it likely needs to have someone with expertise on each platform (web, Android, iOS, Windows) to really be involved to make sure we don't miss anything or leave any weird gaps. It's certainly possible to make a more unified API, but that API may not map as closely to one platform (web) as initially thought. Let me know if you want details on any of the above. I would consider myself an expert in Android accessibility that can speak to any part of that system, and knowledgeable enough about iOS accessibility to make high level suggestions, but not enough of an expert on iOS to give in depth explanations of the technical details required to pull something off. |
Thanks Brett. Are there any other native a11y APIs that are currently unavailable in RN?
If developers need to understand and manage 3+ different a11y APIs for general a11y tasks while using React Native, that would be a serious problem. What we have to decide is a) whether the differences are significant enough that the imperative controls cannot be abstracted behind the ARIA declarative API, and b) whether the use cases are common enough that they must belong in the xplat API (but only be supported by 1 or 2 platforms). There will always be a need for platform-specific APIs in specific scenarios, but I think we should avoid putting those APIs into the xplat layer. We have other mechanisms, such as custom components and hooks, by which platform-specific behaviors could be introduced.
Is this not mostly equivalent to
The
Concatenating the content into the label is exactly what we do for the Android implementation of
Agreed. If we were to do this it looks like we'd be committing to building certain abstractions over native APIs as browsers do. I have no idea what that involves on the native engineering side.
Technically neither does web. This is something we should enforce at the framework level in any case.
This is another iOS-only prop that has no relation to ARIA concepts. I'm not sure what the best replacement would be. I think we could either make iOS behave like other platforms at the framework level (maybe that means media is never inverted?), or perhaps model the API to control this on web equivalents (e.g., the forced-color-adjust style). |
RE: Accessibility Actions This Apple introduction to custom rotors is interesting: https://developer.apple.com/videos/play/wwdc2020/10116/ The first example of the categorized map icons would typically be implemented on web as buttons in either a list of lists, or lists below headings. VoiceOver users can then use the rotor to navigate by category headings. Other examples could perhaps be implemented by React Native, mapping web markup patterns to inferred custom rotors on native platforms. While the rest don't have clear equivalents. There's been some discussion in the W3C ARIA GitHub about how to model these accessibility actions, suggesting they have similarities to custom context menus for accessibility services: w3c/aria#762 I suspect that the built-in accessibility actions we have in React Native could be surfaced to RN devs as events, e.g., we add |
@necolas We're currently looking at adding support for defining text heading levels in react-native-win32 by reusing the existing
Are there any android/iOS contacts I should reach out to to discuss this? Or is the proposal outlined for |
yes I think it's ok. that prop is only implemented by the windows and web forks, and for the same purpose |
Just as something worth noting, I don't think there is any Android equivalent to heading levels, so this property likely will be a no-op on that platform. The only place that Android has any sort of level information like this is with AccessibilityCollectionInfo, which has a boolean isHierarchical saying whether this list should be treated as hierarchical content and whether nested lists should be considered as different levels. There's no control over the actual level other than the depth of the list though, so even if this was set on elements within hierarchical list structures it wouldn't really be applicable. |
Closing this in favor of #496 |
This is a proposal to expand React Native accessibility APIs, and to align those APIs with equivalent web standards, e.g., WAI-ARIA. The aim is to provide developers with a single, familiar accessibility model rather than requiring deep knowledge of the models of each target platform.