From f710b8c4f3247156f64fb2b528a960bf808ef7ac Mon Sep 17 00:00:00 2001 From: James Date: Tue, 8 Feb 2022 17:45:05 -0500 Subject: [PATCH] fix: adds key to RichText based on initialValue --- .../components/forms/field-types/RichText/RichText.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/admin/components/forms/field-types/RichText/RichText.tsx b/src/admin/components/forms/field-types/RichText/RichText.tsx index 14cbe8e2c08..e874a64a1f1 100644 --- a/src/admin/components/forms/field-types/RichText/RichText.tsx +++ b/src/admin/components/forms/field-types/RichText/RichText.tsx @@ -69,6 +69,7 @@ const RichText: React.FC = (props) => { const [loaded, setLoaded] = useState(false); const [enabledElements, setEnabledElements] = useState({}); const [enabledLeaves, setEnabledLeaves] = useState({}); + const [initialValueKey, setInitialValueKey] = useState(''); const renderElement = useCallback(({ attributes, children, element }) => { const matchedElement = enabledElements[element?.type]; @@ -129,6 +130,7 @@ const RichText: React.FC = (props) => { showError, setValue, errorMessage, + initialValue, } = fieldType; const classes = [ @@ -172,6 +174,10 @@ const RichText: React.FC = (props) => { } }, [loaded, elements, leaves]); + useEffect(() => { + setInitialValueKey(JSON.stringify(initialValue || '')); + }, [initialValue]); + if (!loaded) { return null; } @@ -190,6 +196,7 @@ const RichText: React.FC = (props) => { return (