Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-04-18 19:55:51 +00:00
co-authored by renee-png
parent 52e054bf5f
commit ffbb49b523
@@ -59,13 +59,18 @@ export function RichTextEditor({
},
});
// Keep editor in sync when value is reset externally
// Keep editor in sync when value is reset/loaded externally (e.g. opening a saved pleading).
// Only re-sync when the incoming value differs meaningfully from the current editor HTML so
// we don't fight the user's typing on every keystroke.
useEffect(() => {
if (editor && value !== editor.getHTML()) {
editor.commands.setContent(value || "<p></p>", { emitUpdate: false });
if (!editor) return;
const current = editor.getHTML();
const incoming = value || "<p></p>";
if (incoming !== current) {
editor.commands.setContent(incoming, { emitUpdate: false });
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [value === ""]);
}, [value, editor]);
if (!editor) return null;