From ffbb49b52346bb403b69f220eed37e2e941842d0 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 18 Apr 2026 19:55:51 +0000 Subject: [PATCH] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/components/documents/rich-text-editor.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/documents/rich-text-editor.tsx b/src/components/documents/rich-text-editor.tsx index 330cd27..5ccd75b 100644 --- a/src/components/documents/rich-text-editor.tsx +++ b/src/components/documents/rich-text-editor.tsx @@ -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 || "
", { emitUpdate: false }); + if (!editor) return; + const current = editor.getHTML(); + const incoming = value || ""; + if (incoming !== current) { + editor.commands.setContent(incoming, { emitUpdate: false }); } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [value === ""]); + }, [value, editor]); if (!editor) return null;