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

Support arrowup and arrowdown events #511

Merged

Conversation

corymharper
Copy link
Contributor

@corymharper corymharper commented Dec 2, 2020

What:

These changes add support for the arrow up and down keys to userEvent.type.

Why:

Arrow up and down keys are used for various accessibility reasons and are part of regular user actions.

How:

I added two functions, handleArrowDown and handleArrowUp, and tied those into the existing special character map.

Checklist:

  • Documentation
  • Tests
  • Typings N/A
  • Ready to be merged

Unless something unexpected comes up, this is probably ready for merging immediately.

Closes #503

@codecov
Copy link

codecov bot commented Dec 2, 2020

Codecov Report

Merging #511 (8e123a2) into master (e9dd0a6) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #511   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           13        13           
  Lines          664       674   +10     
  Branches       211       211           
=========================================
+ Hits           664       674   +10     
Impacted Files Coverage Δ
src/type.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e9dd0a6...8e123a2. Read the comment docs.

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty solid to me 👍 Just one note about the tests.

src/__tests__/type.js Outdated Show resolved Hide resolved
Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brilliant 👏

@kentcdodds
Copy link
Member

Oh rats, there are merge conflicts. Could you address those?

@corymharper
Copy link
Contributor Author

Oh rats, there are merge conflicts. Could you address those?

Done!

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect! Thank you 👏

@kentcdodds kentcdodds merged commit ecea19c into testing-library:master Dec 3, 2020
@github-actions
Copy link

github-actions bot commented Dec 3, 2020

🎉 This PR is included in version 12.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Shipow
Copy link

Shipow commented Dec 3, 2020

It's really the perfect timing for this, thanks!!!

@bozdoz bozdoz mentioned this pull request Dec 18, 2020
4 tasks
@wilsonmedeiros
Copy link

Hello Everyone, I'm handling a test on input type number, where I expect increase and decrease value when typing on keyboard arrow up and down respectively. The Issue is that nothing happens, the input value remains the same. Someone could look into my code and see what is happening. I believe that userEvent and input are not communicating with each other in this particular event

Code: https://codesandbox.io/s/late-http-ff27ln?file=/src/App.test.tsx

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

Successfully merging this pull request may close these issues.

Add support for arrowdown and arrowup events
4 participants