-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
Recent radio input onChange changes break expected behavior #10739
Comments
Thanks for the detailed report @darth-cheney! cc @nhunzaker @jquense @jquense you've dealt with this the most, can you clarify whether this is/isn't expected? I also noticed that the change events only fire once (keep toggling and it will just stop dispatching events). Is that an issue we're already aware of? |
This was fixed in 15.6.2 and shouldn't exist in 16 |
issue is there on master |
@jquense If you change the versions of the imports to 15.6.2 in by Codepen above, you'll see that the change event still only fires the first time. I am unable to test with React 16 in the Codepen for whatever reason. |
you're right! Sorry about that, i'm not sure how that happened... |
Just to clarify, this also seems to be broken in v16. I swapped out the import in the Codepen with: <script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script> |
broken in v16 too Orz |
Background
I see from this issue thread that recent changes were pushed in
15.6.x
that have – to my mind – broken some of the expected behavior when it comes to firingonChange
events in a group of radio button inputs.I am aware of the conversation in #1471, but the problem it's describing is not exactly the same as this so far as I can tell.
Note that the problem I'm about to describe does not occur in React <=
15.4.x
.Expectations
We would expect an individual radio button's
onChange
to fire in these two conditions (among others):Indeed, native elements work precisely this way:
If you click the above radio buttons and observe the console output, you'll see that the event is firing as expected: only when a desired input's state is being changed to something new.
Here is a Codepen example
React Expectations
The following React component will work as expected in
15.4.x
but not15.6.x
:In
15.4.x
React, this the inputs in this component will work as you'd expect and as the native DOM elements work. This Codepen shows it working properly with 15.4.1In
15.6.x
, theonChange
event seems to only fire once. Here is another Codepen showing it doesn't work when 15.6.1 is imported.It is, of course, entirely possible that I am doing something incorrectly (and have been doing so for a couple of years now), but the breaking change to my components only came with recent updates.
The text was updated successfully, but these errors were encountered: