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

How to auto-save notes #331

Open
1 task
mosofsky opened this issue Feb 18, 2023 · 1 comment
Open
1 task

How to auto-save notes #331

mosofsky opened this issue Feb 18, 2023 · 1 comment

Comments

@mosofsky
Copy link

Checklist

Description

I cannot figure out a way to save the MUIRichTextEditor's value automatically to a database when onChange is fired. I tried a solution that "debounced" the save to the database using lodash.debounce. However, saving to the database causes React to re-rerender the component that contains the MUIRichTextEditor. Since I'm using the defaultValue of MUIRichTextEditor to display what's in the database, the cursor insertion point gets reset to the beginning of the text field. I understand that is because "every time you change the value property you are actually resetting the editor" (issue 52).

I tried another solution where I render MUIRichTextEditor with defaultValue as long as the content is not dirty (i.e. onChange has not been called). However, I did that by sometimes rendering MUIRichTextEditor with defaultValue and sometimes without defaultValue. That did not work at all because React saw these as two completely different components.

So, is there a way to use MUIRichTextEditor where onChange saves the data to a database but not more frequently than say 5 seconds (i.e. debounced)?

@Draccan
Copy link

Draccan commented Jul 9, 2024

Same problem for me

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