From d417e50d52fc0824fb5aaedd3e1208c3e1468bdd Mon Sep 17 00:00:00 2001 From: James Date: Fri, 23 Dec 2022 11:47:16 -0500 Subject: [PATCH] fix: #1747, rich text in arrays improperly updating initialValue when moving rows --- .../components/forms/field-types/RichText/RichText.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/admin/components/forms/field-types/RichText/RichText.tsx b/src/admin/components/forms/field-types/RichText/RichText.tsx index ac3c8d8054..df30966c1f 100644 --- a/src/admin/components/forms/field-types/RichText/RichText.tsx +++ b/src/admin/components/forms/field-types/RichText/RichText.tsx @@ -207,12 +207,12 @@ const RichText: React.FC = (props) => { }, [loaded, readOnly]); useEffect(() => { - // If there is a change to the initial value, we need to reset Slate - // to the new initial value, and clear selection + // If there is a change to the initial value, we need to reset Slate history + // and clear selection because the old selection may no longer be valid + // as returned JSON may be modified in hooks and have a different shape if (Array.isArray(initialValue) && initialValue.length > 0) { if (editor.selection) ReactEditor.deselect(editor); editor.history = { redos: [], undos: [] }; - editor.children = initialValue; } }, [initialValue, editor]);