feat(a11y): automatically set accessible prop with role prop - #57633
feat(a11y): automatically set accessible prop with role prop#57633mdjastrzebski wants to merge 3 commits into
accessible prop with role prop#57633Conversation
accessible with role propaccessible prop with role prop
|
This seems reasonable, but is there any chance we can do this on the native side instead? We should avoid post-processing props in JS for perf reasons. |
|
@javache I did some research and it looks like C++ calculation would be fine for iOS, but on Android we need to have duplicated logic in Kotlin since the ViewManagers use the original JS Hence, I would advise to keep it in JS right now, and migrate multiple prop calculation from JS to C++ as a unified effort when Props 2.0 is available on Android. |
| const { | ||
| 'aria-busy': ariaBusy, | ||
| 'aria-checked': ariaChecked, | ||
| 'aria-disabled': ariaDisabled, | ||
| 'aria-expanded': ariaExpanded, | ||
| 'aria-selected': ariaSelected, | ||
| 'aria-hidden': ariaHidden, | ||
| src, | ||
| ...restProps | ||
| } = props; |
There was a problem hiding this comment.
Extract accessible here (ditto for 'aria-label/accessibilityLabel) - we generally want to extract props once, and avoid passing them both in restProps` and through explicit props.
You'd want to model this like View where we create a single resolvedProps object which we write everything to.
Fine to do this as a follow-up cleanup PR, and overload this one.
There was a problem hiding this comment.
I will submit follow-up for not to muddle the scope
|
@javache has imported this pull request. If you are a Meta employee, you can view this in D113754156. |
Summary:
Setting
roleprop (exceptnone/presentation) automatically setsaccessibleprop onViewandImage. This aligns web behavior when settingroleattribute is enough to add the element into accessibility tree.This aligns also with
Imagealtweb-compat prop which also enablesaccessiblewhen set.The change skips
Text,TextInput, etc as they are implicitly members of accessibility tree by default.This change also intentionally skips
accessibilityRoleas legacy, non-web version.This also helps when using React Strict DOM, as it exposes
roleprop, but does not exposeaccessibleprop, hence settingroleonh.divbasically has no effect. I think this changes is better suited for RN repo though.Changelog:
[GENERAL] [CHANGED] Automatically set
acessibleprop whenroleprop is set (exceptnone/presenation)Test Plan:
Added relevant Fantom tests.