-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
[react-events] usePress from useKeyboard and useTap #16772
[react-events] usePress from useKeyboard and useTap #16772
Conversation
530a56a
to
5d74159
Compare
Change the test code from: // Trigger a click event
input.dispatchEvent(
new MouseEvent('mousedown', {bubbles: true, cancelable: true}),
);
input.dispatchEvent(
new MouseEvent('mouseup', {bubbles: true, cancelable: true}),
); To this: // Trigger a click event
input.dispatchEvent(
new MouseEvent('mousedown', {
bubbles: true,
cancelable: true,
buttons: 1,
}),
);
input.dispatchEvent(
new MouseEvent('mouseup', {
bubbles: true,
cancelable: true,
buttons: 1,
}),
); And it should fix the test as you now check the |
5d74159
to
c0b50d4
Compare
Only 2 tests fail now, and they are related to calling preventDefault on a "virtual" click event that was not caused by the "Enter" key, i.e., a screen-reader dispatched the event. The |
d9cbe74
to
42b6dd6
Compare
Details of bundled changes.Comparing: 494300b...aaa151f react-ui
|
This implements 'usePress' in user-space as a combination of 'useKeyboard' and 'useTap'. The existing 'usePress' API is preserved for now. The previous implementation is moved to 'PressLegacy'.
42b6dd6
to
aaa151f
Compare
This implements
usePress
in user-space as a combination ofuseKeyboard
anduseTap
(in an either/or configuration). The existingusePress
API is preserved for now. The previoususePress
implementation is moved toPressLegacy
.Demo: https://codesandbox.io/s/usepress-usetap-usekeyboard-fcvg7