Skip to content
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

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

Open
1 task done
louie-succio opened this issue Jun 7, 2024 · 1 comment
Open
1 task done
Labels

Comments

@louie-succio
Copy link

Is there an existing issue for this?

  • 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.

@necolas
Copy link
Owner

necolas commented Jun 13, 2024

I'll review a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants