react-aria useButton hook disabling onKeyDown event on custom button component #4950
Replies: 1 comment
-
Yep, we provide onPress as an aggregate of all types of interactions that should result in a "click" on an element. If you're new to the library, I suggest having a read through our blog series on buttons https://react-spectrum.adobe.com/blog/building-a-button-part-1.html it explains what we're doing with onPress in more detail. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all.
I'm integrating the
react-aria
hook library into my codebase to ensure that my custom components properly meet all ARIA accessibility requirements. I've immediately noticed however that when I use the props generated by the library'suseButton
hook as described in the documentation, that a button which was focused with Tab no longer executes itsonClick
event on key press of Enter or Space - functionality that previously worked just fine before integration of the library.The below sandbox illustrates the issue: Tabbing to the green button (the RegularButton component) and pressing Enter or Space will fire the onClick event and render the message. However, toggling to the red button (the ButtonWithReactAria component) and pressing Enter or Space will result in nothing happening.
https://codesandbox.io/p/sandbox/twilight-cloud-np66r3
What am I doing wrong to cause this issue?
EDIT: It looks like the
onPress
event is favored overonClick
with this hook.Beta Was this translation helpful? Give feedback.
All reactions