accessibilityRole="link" is not focusable
See original GitHub issueThe problem
An element with accessibilityRole="link"
, like <TouchableOpacity>
, is not focusable.
<TouchableOpacity accessibilityRole="link" onPress={() => console.log("navigate")}>
<Text>Focus Me!</Text>
</TouchableOpacity>
How to reproduce
Simplified test case: https://codesandbox.io/s/w2n7514m9l
Steps to reproduce:
- Focus the first
<TouchableOpacity accessibilityRole="button">
- Press tab.
Expected behavior
The focused element should be the second <TouchableOpacity accessibilityRole="link">
but instead focus is given to the third <TouchableOpacity accessibilityRole="button">
.
Environment
- Browser: Chrome
- OS: MacOS
Workaround
For now, my workaround is to use:
<TouchableOpacity
accessibilityComponentType="a"
accessible={true}
onPress={() => console.log("navigate")}
>
<Text>Focus Me!</Text>
</TouchableOpacity>
Fix?
Here:
It’s assumed that <a>
is focusable by default. Based on basic testing that might not be true? Not sure how this is specced.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
ARIA: link role - Accessibility - MDN Web Docs
A link widget provides an interactive reference to a resource. The target resource can be either external or local; i.e., either outside or ......
Read more >Element with presentational children has no focusable ...
Description. This rule checks that elements with a role that makes its children presentational do not contain focusable elements.
Read more >aria-hidden elements do not contain focusable elements
Use appropriate ARIA roles, states, and properties. The following examples PASS the aria-hidden="true" elements do not contain focusable elements rule:.
Read more >role='text' should have no focusable descendants
What this Accessibility Rule Checks. Checks each element with the role="text" attribute to guarantee that none of its children are focusable. Learn more:....
Read more >Make links focusable (or use real buttons)
When using a link to trigger JavaScript functionality, make it keyboard focusable by giving it a non-empty href attribute. Or use a real ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So one should not use
accessibilityRole="link"
if you want a focusable element? Maybe this should be documented?Yes, I just ‘faked’ the href, as the linking works with or without it. and no matter what you put in it