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

fix: React onChange/onInput events not triggering on input type="file" file upload #381

Merged

Conversation

ybentz
Copy link
Collaborator

@ybentz ybentz commented Jun 25, 2020

Fixes #380.

What:
This PR fixes a bug in the .upload() function that's very similar to #370. The cause of the bug and the fix are basically the same.

Why:
In React, starting with user-event v12 the onChange and onInput callbacks stopped working for <input type="file" />.

How:
Very similar to #370:

  • Input event: passing the bubbles: true option to the event's options.
  • Change event: Use fireEvent.change instead of fireEvent(input, createEvent('change', ....

Checklist:

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

Notes:
As I mentioned in the related issue, we should probably check the rest of the changes in case some other similar functionality broke with the recent changes.

@ybentz ybentz changed the title Pr/upload fix event bubbling fix: React onChange/onInput events not triggering on input type="file" file upload Jun 25, 2020
@codecov
Copy link

codecov bot commented Jun 25, 2020

Codecov Report

Merging #381 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #381   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           12        12           
  Lines          387       387           
  Branches       111       111           
=========================================
  Hits           387       387           
Impacted Files Coverage Δ
src/upload.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 75bab48...8494123. 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.

Thank you

@kentcdodds kentcdodds merged commit d4db93c into testing-library:master Jun 25, 2020
@kentcdodds
Copy link
Member

@all-contributors please add @ybentz for code and tests

@allcontributors
Copy link
Contributor

@kentcdodds

I've put up a pull request to add @ybentz! 🎉

@kentcdodds
Copy link
Member

Thanks so much for your help! I've added you as a collaborator on the project. Please make sure that you review the other/MAINTAINING.md and CONTRIBUTING.md files (specifically the bit about the commit messages and the git hooks) and familiarize yourself with the code of conduct (we're using the contributor covenant). You might also want to watch the repo to be notified when someone files an issue/PR. Please continue to make PRs as you feel the need (you can make your branches directly on the repo rather than your fork if you want). Thanks! And welcome to the team :)

@kentcdodds
Copy link
Member

🎉 This PR is included in version 12.0.8 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

input type="file" - upload() doesn't trigger onChange in React
2 participants