Add support for arrowdown and arrowup events
See original GitHub issue- Testing-library/user-event` version: 12.2.2
- Testing Framework and version: jest/26.0.15
- DOM Environment: react-dom/17.0.0
What you did:
I have a module I’m migrating from Enzyme over to testing-library, the module is a React hook that for the most part manages keyboard controls to follow accessibility guidelines for dropdown menus. Part of our tests simulate arrowdown
and arrowup
events while focused on list items to ensure the correct resulting focused element is obtained. We ran into this issue while trying to replicate that behavior using userEvent
.
What happened:
userEvent.type
only supports ArrowLeft
and ArrowRight
keys.
Problem description:
While trying to implement tests to replace Enzyme with testing-library we were attempting to use userEvent
instead of fireEvent
where ever possible, as suggested by the documentation. However, we are currently unable to replicate tests that used ArrowDown
and ArrowUp
as that’s just not one of the special characters supported by userEvent.type
.
Suggested solution:
Add ArrowDown
and ArrowUp
as supported special keys for userEvent.type
. Also, while reading over the documentation and through some issues, the documentation for userEvent.type
seems off the mark for the variety of purposes it is used for now:
Writes text inside an or a <textarea>.
This should probably be modified to indicate that it’s used with a variety of types of elements now, or a new method could be added to userEvent
meant for these situations were you aren’t necessarily “typing”.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (8 by maintainers)
Top GitHub Comments
And if you would like, I’m more than willing to pick up the work for this refactoring.
🎉 This issue has been resolved in version 12.5.0 🎉
The release is available on:
npm package (@latest dist-tag)
Your semantic-release bot 📦🚀