logic of default values for the embedded chat

pull/21192/head
Anton Kovalev 11 months ago
parent fbee4fcbb7
commit 09bc5fc6a2

@ -199,7 +199,7 @@ export const useEmbeddedChatbot = () => {
const isInputInOptions = item.select.options.includes(initInputs[item.select.variable]) const isInputInOptions = item.select.options.includes(initInputs[item.select.variable])
return { return {
...item.select, ...item.select,
default: (isInputInOptions ? initInputs[item.select.variable] : undefined) || item.default, default: (isInputInOptions ? initInputs[item.select.variable] : undefined) || item.select.default,
type: 'select', type: 'select',
} }
} }

@ -73,7 +73,7 @@ const InputsFormContent = ({ showTip }: Props) => {
{form.type === InputVarType.select && ( {form.type === InputVarType.select && (
<PortalSelect <PortalSelect
popupClassName='w-[200px]' popupClassName='w-[200px]'
value={inputsFormValue?.[form.variable]} value={inputsFormValue?.[form.variable] ?? form.default ?? ''}
items={form.options.map((option: string) => ({ value: option, name: option }))} items={form.options.map((option: string) => ({ value: option, name: option }))}
onSelect={item => handleFormChange(form.variable, item.value as string)} onSelect={item => handleFormChange(form.variable, item.value as string)}
placeholder={form.label} placeholder={form.label}

Loading…
Cancel
Save