diff --git a/frontend/src/app-components/inputs/AutoCompleteEntitySelect.tsx b/frontend/src/app-components/inputs/AutoCompleteEntitySelect.tsx index 9c8d8725..840a3d31 100644 --- a/frontend/src/app-components/inputs/AutoCompleteEntitySelect.tsx +++ b/frontend/src/app-components/inputs/AutoCompleteEntitySelect.tsx @@ -106,7 +106,7 @@ const AutoCompleteEntitySelect = < return ( - {...(options.length && { value })} + value={value} onChange={onChange} label={label} multiple={multiple} diff --git a/frontend/src/app-components/inputs/AutoCompleteSelect.tsx b/frontend/src/app-components/inputs/AutoCompleteSelect.tsx index e0d5f1a9..439cc6d5 100644 --- a/frontend/src/app-components/inputs/AutoCompleteSelect.tsx +++ b/frontend/src/app-components/inputs/AutoCompleteSelect.tsx @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Hexastack. All rights reserved. + * Copyright © 2025 Hexastack. All rights reserved. * * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. @@ -11,6 +11,7 @@ import Autocomplete, { AutocompleteProps, AutocompleteValue, } from "@mui/material/Autocomplete"; +import stringify from "fast-json-stable-stringify"; import { forwardRef, useCallback, useMemo } from "react"; import { Input } from "@/app-components/inputs/Input"; @@ -112,7 +113,7 @@ const AutoCompleteSelect = < {...rest} ref={ref} size="small" - key={JSON.stringify(value)} + key={`${stringify(options)}_${stringify(value)}`} disabled={isDisabled} defaultValue={selected} multiple={multiple} diff --git a/frontend/src/components/visual-editor/form/ListMessageForm.tsx b/frontend/src/components/visual-editor/form/ListMessageForm.tsx index ac5989b8..10ca9703 100644 --- a/frontend/src/components/visual-editor/form/ListMessageForm.tsx +++ b/frontend/src/components/visual-editor/form/ListMessageForm.tsx @@ -182,7 +182,7 @@ const ListMessageForm = () => { }} defaultValue={content?.fields?.title} render={({ field }) => { - const { onChange, value, ...rest } = field; + const { onChange, ...rest } = field; const options = (contentType?.fields || []).filter( ({ type }) => ContentFieldType.TEXT === type, ); @@ -194,7 +194,6 @@ const ListMessageForm = () => { labelKey="label" label={t("label.title")} multiple={false} - {...(options.length && { value })} {...rest} onChange={(_e, selected) => onChange(selected?.name)} error={!!errors?.options?.["content"]?.fields?.title} @@ -212,7 +211,7 @@ const ListMessageForm = () => { control={control} defaultValue={content?.fields?.subtitle} render={({ field }) => { - const { onChange, value, ...rest } = field; + const { onChange, ...rest } = field; const options = (contentType?.fields || []).filter( ({ type }) => ContentFieldType.TEXT === type || @@ -227,7 +226,6 @@ const ListMessageForm = () => { label={t("label.subtitle")} multiple={false} onChange={(_e, selected) => onChange(selected?.name)} - {...(options.length && { value })} {...rest} /> ); @@ -240,7 +238,7 @@ const ListMessageForm = () => { control={control} defaultValue={content?.fields?.image_url} render={({ field }) => { - const { onChange, value, ...rest } = field; + const { onChange, ...rest } = field; const options = (contentType?.fields || []).filter(({ type }) => [ContentFieldType.FILE].includes(type), ); @@ -253,7 +251,6 @@ const ListMessageForm = () => { label={t("label.image_url")} multiple={false} onChange={(_e, selected) => onChange(selected?.name)} - {...(options.length && { value })} {...rest} /> ); @@ -266,7 +263,7 @@ const ListMessageForm = () => { control={control} defaultValue={content?.fields?.url} render={({ field }) => { - const { onChange, value, ...rest } = field; + const { onChange, ...rest } = field; const options = (contentType?.fields || []).filter(({ type }) => [ContentFieldType.URL].includes(type), ); @@ -279,7 +276,6 @@ const ListMessageForm = () => { label={t("label.url")} multiple={false} onChange={(_e, selected) => onChange(selected?.name)} - {...(options.length && { value })} {...rest} /> );