Topic: Refreshing document metadata replaces unsaved editor content
kaiBuilds63
pro asked 7 days ago
We refresh the document details in the background so that the sidebar shows current ownership information. Whenever that request finishes, unsaved editor text is replaced by the last saved HTML, even if the user is still typing.
An effect copies document.html into the draft state and depends on the complete fetched document object. The document ID does not change during the refresh. We need metadata updates without resetting the active editing session.
Mateusz Lazaru
staff answered 6 days ago
The fetched object is acting as a reset signal for your local draft. Treat loading a different document separately from refreshing that document's metadata. A background refetch should not automatically replace local content once the user has started editing.
Keep the draft in an editing session keyed by document ID, or explicitly guard replacement using the current document ID and dirty state. Please share the fetch and initialization effects if you need help handling the first asynchronous load; simply removing dependencies can leave the initial draft empty or preserve content from the previous document.
https://mdbootstrap.com/docs/react/plugins/wysiwyg-editor/
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Pro
- Premium support: No
- Technology: MDB React
- MDB Version: MDB5 9.0.0
- Device: Desktop
- Browser: Edge
- OS: Windows 11
- Provided sample code: No
- Provided link: No