From ccd5be1322d873d9200b3757c8ec27cbafbd343d Mon Sep 17 00:00:00 2001 From: dominik-zeglen Date: Tue, 19 Nov 2019 12:30:07 +0100 Subject: [PATCH 1/2] Fix disappearing products description --- .../components/ProductCreatePage/ProductCreatePage.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/products/components/ProductCreatePage/ProductCreatePage.tsx b/src/products/components/ProductCreatePage/ProductCreatePage.tsx index d866df2d9..15bb0ca8b 100644 --- a/src/products/components/ProductCreatePage/ProductCreatePage.tsx +++ b/src/products/components/ProductCreatePage/ProductCreatePage.tsx @@ -112,7 +112,11 @@ export const ProductCreatePage: React.FC = ({ set: setAttributeData } = useFormset([]); - const initialDescription = convertToRaw(ContentState.createFromText("")); + // Ensures that it will not change after component rerenders, because it + // generates different block keys and it causes editor to lose its content. + const initialDescription = React.useRef( + convertToRaw(ContentState.createFromText("")) + ); const initialData: FormData = { basePrice: 0, category: "", @@ -219,7 +223,7 @@ export const ProductCreatePage: React.FC = ({ data={data} disabled={disabled} errors={errors} - initialDescription={initialDescription} + initialDescription={initialDescription.current} onChange={change} /> From 8775f876f9876e056f7258c7957115ddd5a220c5 Mon Sep 17 00:00:00 2001 From: dominik-zeglen Date: Tue, 19 Nov 2019 12:38:37 +0100 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77d8f7beb..053f66dd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ All notable, unreleased changes to this project will be documented in this file. - Fix subcategories pagination - #249 by @dominik-zeglen - Update customer's details page design - #248 by @dominik-zeglen - Use Apollo Hooks - #254 by @dominik-zeglen +- Fix disappearing products description - #259 by @dominik-zeglen ## 2.0.0