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

onChange event on radio #8727

Closed
yankouskia opened this issue Jan 9, 2017 · 3 comments
Closed

onChange event on radio #8727

yankouskia opened this issue Jan 9, 2017 · 3 comments

Comments

@yankouskia
Copy link

Could you please, explain this behaviour?

Here: https://jsfiddle.net/69z2wepo/67116/ - clicking on radio always emits onClick and onChange events

Here is example without React: https://jsfiddle.net/8mnjtt8w/4/ - clicking on radio emits only onClick event.

Thank you!

@aweary
Copy link
Contributor

aweary commented Jan 9, 2017

@yankouskia React special cases onChange, meaning it doesn't necessarily correspond to the DOM change event, in order to make it easier to handle inputs. For example, change events usually occur for text inputs on blur, but most people expect them to occur when the input's value is actually changed, so we normalize that. You can see this behavior documented here

Now, that said, this is still unexpected behavior since the radio input's value isn't changed. This was already reported in #1471 and resolved in #5746. But #5746 has not been released yet. We're hoping to get it released soon thanks to the backport PR opened at #8575

tl;dr: we normalize input events in general, but this radio input behavior is wrong and already fixed. We're working on getting it released 👍

@aweary aweary closed this as completed Jan 9, 2017
@yankouskia
Copy link
Author

@aweary , thank you! 👍

@wangcongyi
Copy link

@aweary the lastest version 15.4.2 does not seem to fix the bug ,how to solve the old version of it?

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

No branches or pull requests

3 participants