Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix disappearing products description #259

Merged
merged 2 commits into from
Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ export const ProductCreatePage: React.FC<ProductCreatePageProps> = ({
set: setAttributeData
} = 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 = {
basePrice: 0,
category: "",
Expand Down Expand Up @@ -219,7 +223,7 @@ export const ProductCreatePage: React.FC<ProductCreatePageProps> = ({
data={data}
disabled={disabled}
errors={errors}
initialDescription={initialDescription}
initialDescription={initialDescription.current}
onChange={change}
/>
<CardSpacer />
Expand Down