-
Notifications
You must be signed in to change notification settings - Fork 49.2k
Description
Do you want to request a feature or report a bug?
Bug!
What is the current behavior?
When rendering an input
element of type checkbox
with an onClick
and onChange
handler, onChange
is still called even though event.preventDefault()
is called in the onClick
handler.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template: https://jsfiddle.net/reactjs/69z2wepo/).
What is the expected behavior?
Calling event.preventDefault
in the onClick
handler should prevent the default action from occurring (or undo its effect), which is to update the value of the input
element. This should stop any change
event listener from being invoked. See https://jsfiddle.net/L1eskzsq/ for expected behavior
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
Tested using a build from master, macOS 10.12.2, verified in:
- Chrome 56.0.2924.87 (64-bit)
- Firefox 51.0.1 (64-bit)
Safari 10.0.2 calls the change
event listener in both cases.