Fix disappearing products description
This commit is contained in:
parent
bb8af8938f
commit
ccd5be1322
1 changed files with 6 additions and 2 deletions
|
@ -112,7 +112,11 @@ export const ProductCreatePage: React.FC<ProductCreatePageProps> = ({
|
||||||
set: setAttributeData
|
set: setAttributeData
|
||||||
} = useFormset<ProductAttributeInputData>([]);
|
} = useFormset<ProductAttributeInputData>([]);
|
||||||
|
|
||||||
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 = {
|
const initialData: FormData = {
|
||||||
basePrice: 0,
|
basePrice: 0,
|
||||||
category: "",
|
category: "",
|
||||||
|
@ -219,7 +223,7 @@ export const ProductCreatePage: React.FC<ProductCreatePageProps> = ({
|
||||||
data={data}
|
data={data}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
errors={errors}
|
errors={errors}
|
||||||
initialDescription={initialDescription}
|
initialDescription={initialDescription.current}
|
||||||
onChange={change}
|
onChange={change}
|
||||||
/>
|
/>
|
||||||
<CardSpacer />
|
<CardSpacer />
|
||||||
|
|
Loading…
Reference in a new issue