default value logic for chat input fields

pull/21192/head
Anton Kovalev 11 months ago
parent b1662dfa60
commit 5a6bc30096

@ -219,7 +219,7 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => {
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