-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
TextArea and TextInput can't be pre-populated with value #3013
Comments
This is probably caused by this: useState which takes My proposed solution would be:
In |
|
@emyarod Would this be the case...? Thanks! |
Same here, I just ugraded to 7.3.1 thinking it would fix this, but I was using all my TextInput as fully controlled with value and onChange. Apparently this breaks all fully controlled TextInputs. Are we supposed to have both defaultValue and value now? |
this is caused by |
Yeah I got that, but before 7.3, i.e. in 7.2, controlled text inputs were working fine with value only. We have hundreds of them, that's kind of a breaking change. So I'd like to know if it's going to stay like this and I have to update them all, or it's a temporary fix and 7.4 will put back what we had in 7.2 :) |
I see, so it would be best modify the PR so that const [inputVal, setInput] = useState(value || defaultValue); |
Yes, I think it would help a lot of people! :) |
got it! will make that change to #3097 |
Hi everybody, I created examples based in the code snipped in this issue, both use the same code but different versions of carbon-components / carbon-components-react:
I think that the main issue is that the
Maybe, as in version 10.2.0 / 7.2.0, the In any case, as you can see in the code snippets, there is a regression here. |
thanks for the codesandbox examples @EAlexRojas ! I believe this is addressed in #3097 now, just added a |
What package(s) are you using?
carbon-components
- 10.3.0carbon-components-react
- 7.3.0Detailed description
Since I've updated
carbon-components
to 10.3.0 andcarbon-components-react
to 7.3.0, both the TextInput and the TextArea components don't initially passvalue
props down to the actual elements - which means the fields cannot be prepopulated.This does not happen in previous versions - to see this yourself, use the CodeSandbox below and use 10.2.0/7.2.0. There, the fields are populated with whatever you pass as
value
to the Carbon component.I can see the issue in the latest Chrome and Firefox.
Steps to reproduce the issue
See this reduced code snippet in CodeSandbox.
Notes
When looking at the tree using the React DevTools, you can see the Carbon components receive the
value
prop, but the<input>
/<textarea>
elements always get an empty string for theirvalue
.The text was updated successfully, but these errors were encountered: