Skip to content

Commit

Permalink
Merge pull request #581 from Hexastack/575-bug-block-list-is-not-load…
Browse files Browse the repository at this point in the history
…ing-the-full-content

fix(frontend): resolve block list edit form bug
  • Loading branch information
marrouchi authored Jan 20, 2025
2 parents d410829 + 377ef71 commit d24521c
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions frontend/src/components/visual-editor/form/ListMessageForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,17 +181,19 @@ const ListMessageForm = () => {
}}
defaultValue={content?.fields?.title}
render={({ field }) => {
const { onChange, ...rest } = field;
const { onChange, value, ...rest } = field;
const options = (contentType?.fields || []).filter(
({ type }) => ContentFieldType.TEXT === type,
);

return (
<AutoCompleteSelect<ContentField, "label", false>
options={(contentType?.fields || []).filter(
({ type }) => ContentFieldType.TEXT === type,
)}
options={options}
idKey="name"
labelKey="label"
label={t("label.title")}
multiple={false}
{...(options.length && { value })}
{...rest}
onChange={(_e, selected) => onChange(selected?.name)}
error={!!errors?.options?.["content"]?.fields?.title}
Expand All @@ -209,20 +211,22 @@ const ListMessageForm = () => {
control={control}
defaultValue={content?.fields?.subtitle}
render={({ field }) => {
const { onChange, ...rest } = field;
const { onChange, value, ...rest } = field;
const options = (contentType?.fields || []).filter(
({ type }) =>
ContentFieldType.TEXT === type ||
ContentFieldType.TEXTAREA === type,
);

return (
<AutoCompleteSelect<ContentField, "label", false>
options={(contentType?.fields || []).filter(
({ type }) =>
ContentFieldType.TEXT === type ||
ContentFieldType.TEXTAREA === type,
)}
options={options}
idKey="name"
labelKey="label"
label={t("label.subtitle")}
multiple={false}
onChange={(_e, selected) => onChange(selected?.name)}
{...(options.length && { value })}
{...rest}
/>
);
Expand All @@ -235,18 +239,20 @@ const ListMessageForm = () => {
control={control}
defaultValue={content?.fields?.image_url}
render={({ field }) => {
const { onChange, ...rest } = field;
const { onChange, value, ...rest } = field;
const options = (contentType?.fields || []).filter(({ type }) =>
[ContentFieldType.FILE].includes(type),
);

return (
<AutoCompleteSelect<ContentField, "label", false>
options={(contentType?.fields || []).filter(({ type }) =>
[ContentFieldType.FILE].includes(type),
)}
options={options}
idKey="name"
labelKey="label"
label={t("label.image_url")}
multiple={false}
onChange={(_e, selected) => onChange(selected?.name)}
{...(options.length && { value })}
{...rest}
/>
);
Expand All @@ -259,18 +265,20 @@ const ListMessageForm = () => {
control={control}
defaultValue={content?.fields?.url}
render={({ field }) => {
const { onChange, ...rest } = field;
const { onChange, value, ...rest } = field;
const options = (contentType?.fields || []).filter(({ type }) =>
[ContentFieldType.URL].includes(type),
);

return (
<AutoCompleteSelect<ContentField, "label", false>
options={(contentType?.fields || []).filter(({ type }) =>
[ContentFieldType.URL].includes(type),
)}
options={options}
idKey="name"
labelKey="label"
label={t("label.url")}
multiple={false}
onChange={(_e, selected) => onChange(selected?.name)}
{...(options.length && { value })}
{...rest}
/>
);
Expand Down

0 comments on commit d24521c

Please sign in to comment.