You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do you want to request a feature or report a bug?
bug
What is the current behavior?
When using ReactDOM.render checkboxes with jsx attribute checked={null} will have a checked value from their DOM element of false. When using TestUtils and TestUtils.Simulate the same configuration above for checked={null} will result in checkboxElm.checked to be true.
**If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
What is the expected behavior?
expected behavior is that TestUtils would mimic actual DOM fragment, i.e. jsx property checked={null} results in someCheckboxElm.checked to be false
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
This worked in 15.1.0 but stopped working in >= 15.2.0
The text was updated successfully, but these errors were encountered:
dtothefp
changed the title
Since 15.2.0 TestUtils for Radios and Checkboxes Unexpected Behavior for nullchecked values
Since 15.2.0 TestUtils for Radios and Checkboxes Unexpected Behavior for nullchecked attributes
Sep 5, 2016
I pushed for this in #7530. The explanation I was given was that "null" activates uncontrolled mode for inputs, which is why you are seeing the behavior.
@nhunzaker thanks for the heads up. from reading that I'm still not clear on why I'm seeing null work for toggling checked unless I use the TestUtils...seems inconsistent?
Switching checked to null switches your input to be uncontrolled.
React 16 warns about this:
I think what happens next is: when you click on it manually, the browser toggles it (now that it’s uncontrolled). So you see it changing. Whereas if you simulate an event with TestUtils, nothing happens because your click handler just switched it to uncontrolled mode but there was no real click.
As the warning suggests, don’t use null unless you mean for the component to be uncontrolled (in which case you should keep it uncontrolled for its whole lifetime).
Do you want to request a feature or report a bug?
bug
What is the current behavior?
When using
ReactDOM.render
checkboxes with jsx attributechecked={null}
will have achecked
value from their DOM element offalse
. When usingTestUtils
andTestUtils.Simulate
the same configuration above forchecked={null}
will result incheckboxElm.checked
to betrue
.**If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
demo here https://jsbin.com/ciwavowoqe/1/edit?html,js,console,output
What is the expected behavior?
expected behavior is that TestUtils would mimic actual DOM fragment, i.e. jsx property
checked={null}
results insomeCheckboxElm.checked
to befalse
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
This worked in
15.1.0
but stopped working in >=15.2.0
The text was updated successfully, but these errors were encountered: