-
Notifications
You must be signed in to change notification settings - Fork 273
*ByRole: return only elements with implicit or explicit accessible={true}
prop
#1180
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
Comments
I'm willing to work on that :) |
@MattAgn great! Go ahead. I've got some initial research done on this subject:
|
Alright sounds good to me! |
There seems to be a difference between "accessible element" vs "accessibility element". We already have RN docs uses the "accessibility element" naming so I would stick with it. |
Oh indeed, did not see it was the term used in the RN documentation, fine by me then 👍 |
Closed by #1244 |
Describe the Feature
This is a proposed tweak to
*ByRole
query. It can be treated as either a fix or a (breaking) change.Currently
getByRole
query is based on explicit role set inaccessibilityRole
prop. Other props are not taken into account (at least until #1064 is merged). This behaviour while basic can be problematic as according to screen readers, elements withaccessible={false}
(either explicit or implicit) are not focusable by screen reader.This manifests in relatively common RN pattern:
Under current implementation
getByRole('button', { name: "Action" })
would select both outer and inner pressables. After implementing the proposed change it would select only the inner one.Possible Implementations
getByRole
using the same criteria as now (host component, equalaccessibilityRole
) but also needs to be consideredaccessibility element
(i.e. be focusable).accessible={true}
accessible
prop (e.g.Text
,TextInput
), but can have their "focusability" disabled by settingaccessible={false}
View
is not consider focusablePressable
,TouchableOpacity
which render to hostView
actually set explicitaccessible={true}
prop on the viewIn more practical terms we could use something like
isAccessibilityElement
to check for focusable state:Then this criteria should be added to
*ByRole
query.This change should not affect other general purpose queries as
*ByText
or*ByTestId
. It may be worth considering applying it to some other a11y-related queries, which would make only sense if selected view is accessible:*ByA11yValue
,*ByA11State
.Related Issues
#1152 - initial source for issue
#1163 - related discussion
#1064 - hidden query option
CC: @AugustinLF @pierrezimmermannbam @MattAgn @thymikee
The text was updated successfully, but these errors were encountered: