question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

accessibilityRole="link" is not focusable

See original GitHub issue

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

  1. Focus the first <TouchableOpacity accessibilityRole="button">
  2. 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:

https://github.com/necolas/react-native-web/blob/eb7706260813f843a9d7d7ad90e2d612d11f867f/packages/react-native-web/src/modules/createDOMProps/index.js#L123-L125

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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
calebmercommented, Mar 5, 2019

So one should not use accessibilityRole="link" if you want a focusable element? Maybe this should be documented?

0reactions
rverunacommented, Mar 1, 2021

Yes, I just ‘faked’ the href, as the linking works with or without it. and no matter what you put in it

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found