From f3367082270e8d6a04950a82163db71469c9a82a Mon Sep 17 00:00:00 2001 From: Konstantin Date: Tue, 16 Jul 2024 07:42:33 +0200 Subject: [PATCH] fix: editor doesn't show up for undefined field values --- .../admin/src/components/RichText/index.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/strapi-plugin-rich-text/admin/src/components/RichText/index.tsx b/packages/strapi-plugin-rich-text/admin/src/components/RichText/index.tsx index 504d87f..79bf84e 100644 --- a/packages/strapi-plugin-rich-text/admin/src/components/RichText/index.tsx +++ b/packages/strapi-plugin-rich-text/admin/src/components/RichText/index.tsx @@ -1,4 +1,4 @@ -import { useCallback, useMemo } from "react"; +import { useCallback, useEffect, useMemo, useState } from "react"; import { Stack } from "@strapi/design-system/Stack"; import { Box } from "@strapi/design-system/Box"; import { Field, FieldLabel } from "@strapi/design-system/Field"; @@ -54,6 +54,7 @@ export default function RichText({ error, }: RichTextProps) { const { formatMessage } = useIntl(); + const [shouldMountEditor, setShouldMountEditor] = useState(false); const content = useMemo(() => { if (value) { @@ -76,6 +77,10 @@ export default function RichText({ [onChange, name] ); + useEffect(() => { + setShouldMountEditor(true); + }, []); + return ( @@ -84,7 +89,7 @@ export default function RichText({ {formatMessage(intlLabel)} - {content && ( + {shouldMountEditor && (