react-native-web
react-native-web copied to clipboard
Pressable's onPress method is not triggered by "enter" key when role="link"
Is there an existing issue for this?
- [X] I have searched the existing issues
Describe the issue
When using the Pressable component from react-native, the onPress prop does not trigger when the role="link" and the element has focus and "enter" is tapped from the keyboard. The only way currently to have "enter" trigger a Pressable with role="link" is to use onPressOut.
Expected behavior
When a Pressable has onPress and role="link" clicking and hitting "enter" on the Pressable should trigger onPress
Steps to reproduce
- Use
<Pressable role="link" onPress={() => console.log("onPress triggered")} /> - Focus on pressable element using tab key
- Hit "enter"
- Notice there is no log in the console
- Click the pressable
- Notice there is a log in the console
Test case
https://codesandbox.io/p/sandbox/clever-joana-w2r4hd?file=%2Fsrc%2FApp.js
Additional comments
The reason this is coming up is because of an accessibility audit we are going through where button that act as links need to be marked up as so.
I'll review a PR