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/onchange text input #147

Merged
merged 2 commits into from Jul 29, 2019
Merged

Fix/onchange text input #147

merged 2 commits into from Jul 29, 2019

Conversation

Gpx
Copy link
Member

@Gpx Gpx commented Jul 20, 2019

Rebase of #141

It looks like React handles the change event differently from what a browser does.

In a browser:

keydown
keypress
input
keyup
change

And change fires only after the input loses focus.

In React this is the sequence:

keydown
keypress
input
change
keyup

change fires without need to blur the input.

You can try both sequences here and here.

@calebeby what do you think? Does it make sense to you?

@calebeby
Copy link
Contributor

calebeby commented Jul 20, 2019

@Gpx In react for text inputs, onChange and onInput are exactly the same. For text inputs, React's onChange actually listens to the input event. So if user-event fires a DOM change event the same way a real user does, it won't affect React

In Preact and Vue, onChange/@change listen for the actual DOM change event, and if people want to listen for the input event then they use onInput/@input

@Gpx Gpx force-pushed the fix/onchange-text-input branch from 3bd6c85 to 8ea17a1 Compare July 29, 2019 07:59
@codecov-io
Copy link

codecov-io commented Jul 29, 2019

Codecov Report

Merging #147 into master will increase coverage by 0.05%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #147      +/-   ##
==========================================
+ Coverage   96.52%   96.58%   +0.05%     
==========================================
  Files           1        1              
  Lines         115      117       +2     
  Branches       27       27              
==========================================
+ Hits          111      113       +2     
  Misses          4        4
Impacted Files Coverage Δ
src/index.js 96.58% <100%> (+0.05%) ⬆️

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 ceff569...8ea17a1. Read the comment docs.

@Gpx Gpx merged commit c5df100 into master Jul 29, 2019
@Gpx Gpx deleted the fix/onchange-text-input branch July 29, 2019 08:03
@Gpx Gpx mentioned this pull request Jul 29, 2019
@Gpx
Copy link
Member Author

Gpx commented Jul 29, 2019

🎉 This PR is included in version 4.2.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Gpx Gpx added the released label Jul 29, 2019
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.

None yet

3 participants