Fix rich text editor content not being saved (#1202)
* Fix rich text editor content not being saved * Add a temporary workaround to EditorJS issue
This commit is contained in:
parent
88e5e75563
commit
df7ac2dd45
4 changed files with 11 additions and 5 deletions
|
@ -70,6 +70,7 @@ interface AttributeRowProps extends AttributeRowHandlers {
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
error: ProductErrorWithAttributesFragment | PageErrorWithAttributesFragment;
|
error: ProductErrorWithAttributesFragment | PageErrorWithAttributesFragment;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
|
entityId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const AttributeRow: React.FC<AttributeRowProps> = ({
|
const AttributeRow: React.FC<AttributeRowProps> = ({
|
||||||
|
@ -85,7 +86,8 @@ const AttributeRow: React.FC<AttributeRowProps> = ({
|
||||||
onReferencesReorder,
|
onReferencesReorder,
|
||||||
onChange,
|
onChange,
|
||||||
fetchAttributeValues,
|
fetchAttributeValues,
|
||||||
fetchMoreAttributeValues
|
fetchMoreAttributeValues,
|
||||||
|
entityId
|
||||||
}) => {
|
}) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const classes = useStyles({});
|
const classes = useStyles({});
|
||||||
|
@ -160,6 +162,7 @@ const AttributeRow: React.FC<AttributeRowProps> = ({
|
||||||
return (
|
return (
|
||||||
<BasicAttributeRow label={attribute.label}>
|
<BasicAttributeRow label={attribute.label}>
|
||||||
<RichTextEditor
|
<RichTextEditor
|
||||||
|
key={entityId} // temporary workaround, TODO: refactor rich text editor
|
||||||
name={`attribute:${attribute.label}`}
|
name={`attribute:${attribute.label}`}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
error={!!error}
|
error={!!error}
|
||||||
|
|
|
@ -44,6 +44,7 @@ export interface AttributesProps extends AttributeRowHandlers {
|
||||||
ProductErrorWithAttributesFragment | PageErrorWithAttributesFragment
|
ProductErrorWithAttributesFragment | PageErrorWithAttributesFragment
|
||||||
>;
|
>;
|
||||||
title?: React.ReactNode;
|
title?: React.ReactNode;
|
||||||
|
entityId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const useStyles = makeStyles(
|
const useStyles = makeStyles(
|
||||||
|
@ -116,6 +117,7 @@ const Attributes: React.FC<AttributesProps> = ({
|
||||||
attributeValues,
|
attributeValues,
|
||||||
errors,
|
errors,
|
||||||
title,
|
title,
|
||||||
|
entityId = "_defaultId",
|
||||||
...props
|
...props
|
||||||
}) => {
|
}) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
@ -162,6 +164,7 @@ const Attributes: React.FC<AttributesProps> = ({
|
||||||
<React.Fragment key={attribute.id}>
|
<React.Fragment key={attribute.id}>
|
||||||
{attributeIndex > 0 && <Hr />}
|
{attributeIndex > 0 && <Hr />}
|
||||||
<AttributeRow
|
<AttributeRow
|
||||||
|
entityId={entityId}
|
||||||
attribute={attribute}
|
attribute={attribute}
|
||||||
attributeValues={attributeValues}
|
attributeValues={attributeValues}
|
||||||
error={error}
|
error={error}
|
||||||
|
|
|
@ -42,10 +42,8 @@ const RichTextEditor: React.FC<RichTextEditorProps> = ({
|
||||||
holder: editorContainer.current,
|
holder: editorContainer.current,
|
||||||
logLevel: "ERROR" as LogLevels,
|
logLevel: "ERROR" as LogLevels,
|
||||||
onChange: async api => {
|
onChange: async api => {
|
||||||
if (!api.readOnly) {
|
const savedData = await api.saver.save();
|
||||||
const savedData = await api.saver.save();
|
onChange(savedData);
|
||||||
onChange(savedData);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
onReady: () => {
|
onReady: () => {
|
||||||
// FIXME: This throws an error and is not working
|
// FIXME: This throws an error and is not working
|
||||||
|
|
|
@ -227,6 +227,7 @@ const ProductVariantPage: React.FC<ProductVariantPageProps> = ({
|
||||||
<div>
|
<div>
|
||||||
<VariantDetailsChannelsAvailabilityCard variant={variant} />
|
<VariantDetailsChannelsAvailabilityCard variant={variant} />
|
||||||
<Attributes
|
<Attributes
|
||||||
|
entityId={variant?.id}
|
||||||
title={intl.formatMessage(messages.nonSelectionAttributes)}
|
title={intl.formatMessage(messages.nonSelectionAttributes)}
|
||||||
attributes={data.attributes.filter(
|
attributes={data.attributes.filter(
|
||||||
attribute =>
|
attribute =>
|
||||||
|
@ -248,6 +249,7 @@ const ProductVariantPage: React.FC<ProductVariantPageProps> = ({
|
||||||
/>
|
/>
|
||||||
<CardSpacer />
|
<CardSpacer />
|
||||||
<Attributes
|
<Attributes
|
||||||
|
entityId={variant?.id}
|
||||||
title={intl.formatMessage(
|
title={intl.formatMessage(
|
||||||
messages.selectionAttributesHeader
|
messages.selectionAttributesHeader
|
||||||
)}
|
)}
|
||||||
|
|
Loading…
Reference in a new issue