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
Editable: setting controlled value does not propagate into Editable's internal value #5670
Comments
Thank you for creating a reproduction! ✨ I updated the codesandbox with some logs to get more insight: https://codesandbox.io/s/chakra-ui-issue-5670-j0q3p5?file=/src/App.tsx Seems like the previous value inside Editable is only updated, if Editable itself initiates the update. chakra-ui/packages/editable/src/use-editable.ts Lines 107 to 117 in 577aeb9
The linked PR did not introduce the issue, it was already present in 1.7.2. I think it is missing an Effect similar to this: React.useEffect(() => {
setPreviousValue(valueProp)
}, [valueProp]) |
I think a more straight forward solution would be to set |
Hej @TimKolberger @kk21 I also took a look at this and came to another approach which gives the user a little bit more control regarding the I made by registering to But setting the value in the |
When adjusting my PR I noticed one drawback to call when which leaves us with the same error |
…tdated data when controlled
…tdated data when controlled
…utdated data when controlled
…utdated data when controlled
@TimKolberger will now set the |
…utdated data when controlled
Description
Using React useState to control the value of Editable, calling setState does not seem to change the internal value of Editable.
Link to Reproduction
https://codesandbox.io/s/naughty-glade-ufqr78?file=/pages/index.tsx
Steps to reproduce
Chakra UI Version
1.8.6
Browser
Google Chrome 99
Operating System
Additional Information
No response
The text was updated successfully, but these errors were encountered: