Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Fix exploding seo form

Dominik Żegleńe2d37e3900e7
diff --git a/saleor/static/dashboard-next/products/components/ProductDetailsForm/ProductDetailsForm.tsx b/saleor/static/dashboard-next/products/components/ProductDetailsForm/ProductDetailsForm.tsx
index 071ea8c3fe..eb60239da7 100644
--- a/saleor/static/dashboard-next/products/components/ProductDetailsForm/ProductDetailsForm.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductDetailsForm/ProductDetailsForm.tsx
@@ -13,7 +13,6 @@ import CardTitle from "../../../components/CardTitle";
import FormSpacer from "../../../components/FormSpacer";
import RichTextEditor from "../../../components/RichTextEditor";
import i18n from "../../../i18n";
-import { maybe } from "../../../misc";
import { ProductDetails_product } from "../../types/ProductDetails";
import { FormData as CreateFormData } from "../ProductCreatePage";
import { FormData as UpdateFormData } from "../ProductUpdatePage";
@@ -43,7 +42,6 @@ export const ProductDetailsForm = withStyles(styles, {
data,
disabled,
errors,
- product,
onChange
}: ProductDetailsFormProps) => (
<Card>
@@ -67,7 +65,7 @@ export const ProductDetailsForm = withStyles(styles, {
disabled={disabled}
error={!!errors.descriptionJson}
helperText={errors.descriptionJson}
- initial={maybe(() => JSON.parse(product.descriptionJson))}
+ initial={data.description}
label={i18n.t("Description")}
name="description"
onChange={onChange}
diff --git a/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx b/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx
index 61e76a235c..ab4ad8a63a 100644
--- a/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductUpdatePage/ProductUpdatePage.tsx
@@ -1,4 +1,4 @@
-import { RawDraftContentState } from "draft-js";
+import { convertFromRaw, RawDraftContentState } from "draft-js";
import * as React from "react";
import AppHeader from "../../../components/AppHeader";
@@ -158,8 +158,8 @@ export const ProductUpdate: React.StatelessComponent<ProductUpdateProps> = ({
}
})),
publicationDate: maybe(() => product.publicationDate),
- seoDescription: maybe(() => product.seoDescription),
- seoTitle: maybe(() => product.seoTitle),
+ seoDescription: maybe(() => product.seoDescription) || "",
+ seoTitle: maybe(() => product.seoTitle) || "",
sku: maybe(() =>
product.productType.hasVariants
? undefined
@@ -253,7 +253,11 @@ export const ProductUpdate: React.StatelessComponent<ProductUpdateProps> = ({
title={data.seoTitle}
titlePlaceholder={data.name}
description={data.seoDescription}
- descriptionPlaceholder={data.description}
+ descriptionPlaceholder={maybe(() =>
+ convertFromRaw(data.description)
+ .getPlainText()
+ .slice(0, 300)
+ )}
loading={disabled}
onClick={onSeoClick}
onChange={change}