diff --git a/frontend/src/components/visual-editor/form/ListMessageForm.tsx b/frontend/src/components/visual-editor/form/ListMessageForm.tsx index ae39c995..a0138239 100644 --- a/frontend/src/components/visual-editor/form/ListMessageForm.tsx +++ b/frontend/src/components/visual-editor/form/ListMessageForm.tsx @@ -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 ( - 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} @@ -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 ( - 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} /> ); @@ -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 ( - 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} /> ); @@ -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 ( - 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} /> );