feat: default value option for select input fields (#21192)

Co-authored-by: crazywoola <427733928@qq.com>
Co-authored-by: GuanMu <ballmanjq@gmail.com>
This commit is contained in:
Anton Kovalev
2025-07-28 10:37:23 +03:00
committed by GitHub
parent fce126b206
commit 15757110cf
24 changed files with 113 additions and 11 deletions

View File

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

View File

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

View File

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

View File

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