react-native-web icon indicating copy to clipboard operation
react-native-web copied to clipboard

Pressable's onPress method is not triggered by "enter" key when role="link"

Open louie-succio opened this issue 1 year ago • 1 comments

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

  1. Use <Pressable role="link" onPress={() => console.log("onPress triggered")} />
  2. Focus on pressable element using tab key
  3. Hit "enter"
  4. Notice there is no log in the console
  5. Click the pressable
  6. 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.

louie-succio avatar Jun 07 '24 22:06 louie-succio

I'll review a PR

necolas avatar Jun 13 '24 20:06 necolas