Skip to content
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

Programmatic field clearing does not work correctly #176

Closed
RomanChumakov opened this issue May 27, 2021 · 5 comments
Closed

Programmatic field clearing does not work correctly #176

RomanChumakov opened this issue May 27, 2021 · 5 comments

Comments

@RomanChumakov
Copy link

Hello!
I found that when setting the md-editor value programmatically, md-editor appears to be half-cleared. The Markdown is cleared immediately. But the Textarea is not cleared until I switch to the preview mode and then back to previous mode.
It looks like the Textarea is not updated when the value is changed directly, until it is refreshed by changing mode.

@jaywcjlove
Copy link
Member

@RomanChumakov Can you provide a reproducible example?

@RomanChumakov
Copy link
Author

I created a simple example using creat-react-app here: https://github.com/RomanChumakov/react-md-editor-bug-demonstration
I also recorded a video based on this example

simplescreenrecorder-2021-05-28_14.32.13.mp4

@jaywcjlove
Copy link
Member

https://github.com/RomanChumakov/react-md-editor-bug-demonstration/blob/97ab1b703d3d6ee22630ac5f6375d04b796532fa/src/App.js#L22

<MDEditor
    className = "product-md-editor"
    onChange = {value => formik.setFieldValue('text', value)}
-    value = {formik.values.text}
+    value = {formik.values.text || ''}
/>

@RomanChumakov

jaywcjlove added a commit that referenced this issue May 28, 2021
@jaywcjlove
Copy link
Member

@RomanChumakov

Or, Upgrade + @uiw/react-md-editor@3.3.2

@RomanChumakov
Copy link
Author

@jaywcjlove
Thank you for such a quick response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants