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: Native radio input firing onChange callback twice on click #791
Conversation
Size Change: +4 B (0%) Total Size: 256 kB
ℹ️ View Unchanged
|
Deploy preview for reakit ready! Built with commit 065887f |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 065887f:
|
Codecov Report
@@ Coverage Diff @@
## master #791 +/- ##
=======================================
Coverage 95.44% 95.44%
=======================================
Files 229 229
Lines 3493 3494 +1
Branches 914 950 +36
=======================================
+ Hits 3334 3335 +1
Misses 158 158
Partials 1 1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome @david-szabo97! Thanks a lot!
I wonder if we can force React to fire this event by using something similar to this so we don't need to call the onChange
prop ourselves: https://github.com/reakit/reakit/blob/57b1238e714bb4dda3984d62268313c180fcc6a8/packages/reakit/src/Composite/__utils/setTextFieldValue.ts#L1-L15
With that, React will fire the onChange event on text inputs, but maybe there's a similar solution for non-native radio and checkbox.
Fixes #790
change
event is fired for native radio inputs by the browser. Therefore we don't need to fire it when we click on a native radio.How to test?
Regression test included
Does this PR introduce breaking changes?
No