-
Notifications
You must be signed in to change notification settings - Fork 47.6k
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
fixes textarea not changing when value changes to null (issue #2533) #3041
Conversation
That doesn't actually work for |
It should also reset to |
Can't test right now. I'll have to check that later... Regarding your 2nd point with the |
@martinstein The only way to clear uncontrolled inputs is to physically set |
I didn't quite understand what you mean there, sorry. I think we are talking about 2 different use cases. My case, where this issue trips me up is this:
Of course, after the user has changed, the textarea is still/should stay controlled even though the value is now Maybe that helps to clarify. Could you explain your case? |
Yes, so
Huh? If PS. It seems like you're thinking about this from a use-case perspective, that's something you should implement as a custom component, wrapping an input. This has to make sense from a technical perspective in React, where all you know is that you're going from one state to another, but more than that, the previous state is irrelevant. Rendering with the same props, at any time, should present the same output except for uncontrolled inputs, but rendering an uncontrolled input should either set it to |
Okay, I get your first point. With an empty Yeah, by definition you are right. I find React's definition in this regard somewhat unfortunate, similar to the thoughs of @rymohr here: In my case, the way the form is used is still the same, even after the That's why I find React`s definition a little bit weird. It is still the same textarea, with identical behavior in all cases (a controlled update of the value after some changes), but if that value is null, we now call it "uncontrolled". But anyway, your suggestion with |
4885e92
to
a1358f9
Compare
@syranide You were right. My (old) pull request didn't support I've updated the pull request. Now it works for |
stub.replaceProps({value: null, onChange: emptyFunction}); | ||
expect(node.value).toEqual(''); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need some more tests here. What's the expected behavior when there is a defaultValue
? What if defaultValue
also changes? Should null
and undefined
behave differently?
I commented in the issue for a bit more discussion before we make a final decision.
Is this will be merged? Because |
@iam4x Just because it resets doesn't mean it's a good idea to rely on this behavior. |
Superseded by #5013 |
This is a fix for issue #2533.
I've just signed the CLA, too.