-
Notifications
You must be signed in to change notification settings - Fork 239
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
Add support for arrowdown and arrowup events #503
Comments
It would be difficult to implement this consistently for textareas: #404 (comment) You mentioned adding other events, that might work better in this case. What exactly are |
Specifically I am working with a React hook that manages focus to meet accessibility standards for dropdown menus. In the scope of that, arrow up and down moves focus between menu items, very similarly to how a select menu might work but with a variety of elements (Think like a group of Just for example's sake here is the demo. |
This is a good point. We should add support for this situation. Maybe for textarea/input it could just go to the start/end of the input |
Okay, so you're suggesting that it would be an extension of the behavior of |
Correct. It would be used like so: |
Do you believe the concern you mentioned in the comment by @nickmccurdy is still something of a concern for the implementation, or is an expecation that it will go to the beginning or end of the input enough? |
And if you would like, I'm more than willing to pick up the work for this refactoring. |
Actually, I'm thinking we should probably only fire the events, and not change the selection range. And you're more than welcome to give this a go :) |
🎉 This issue has been resolved in version 12.5.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
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
andarrowup
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 usinguserEvent
.What happened:
userEvent.type
only supportsArrowLeft
andArrowRight
keys.Problem description:
While trying to implement tests to replace Enzyme with testing-library we were attempting to use
userEvent
instead offireEvent
where ever possible, as suggested by the documentation. However, we are currently unable to replicate tests that usedArrowDown
andArrowUp
as that's just not one of the special characters supported byuserEvent.type
.Suggested solution:
Add
ArrowDown
andArrowUp
as supported special keys foruserEvent.type
. Also, while reading over the documentation and through some issues, the documentation foruserEvent.type
seems off the mark for the variety of purposes it is used for now: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".The text was updated successfully, but these errors were encountered: