-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Warn if checkbox changes controlledness #7544
Comments
I'd like to give it a try. Is there anything else I need to know before I pick this up? |
@marcin-mazurek Sounds good. I'd recommend looking at the issues I linked to collect any background and/or ideas. Also, we should add a couple of unit tests to verify the new functionality and make sure we don't regress it again. |
It seems like determining controlledness is not consistent. The validation treats component as uncontrolled only when https://facebook.github.io/react/tips/controlled-input-null-value.html - this page suggests that null is considered a uncontrolled value, but this is a text input. No mention about a checkbox/radio input. What do you think should happen when checkbox has It's just proof of concept, not the final solution. The final solution requires some more work to implement consistent solution everywhere. At present, when switching from a controlled value of a text input, we're getting following warning:
This comes from |
Should behave exactly as setting it to undefined does.
Yes, that looks approximately correct to me. Left an inline comment.
Yeah, probably true. Historically we've generally tried to treat |
…and from null to boolean (facebook#7544)
Hey @jimfb. Take a look at #7603 please. As I mentioned in the PR, there aren't any warnings for changing controlledness for textarea and select. Is this something we should improve? |
We should be warning if a controlled component becomes uncontrolled, or vice versa.
I thought this was fixed in #5821, but apparently it was either not fixed for checkbox components, or maybe I subsequently broke it in #7003 (or similar). Regardless, we should fix it.
Demo of case that should warn: https://jsfiddle.net/s4742gkk/
The text was updated successfully, but these errors were encountered: