diff --git a/arroyo-console/src/routes/connections/JsonForm.tsx b/arroyo-console/src/routes/connections/JsonForm.tsx index 11731ba93..ce6a7487b 100644 --- a/arroyo-console/src/routes/connections/JsonForm.tsx +++ b/arroyo-console/src/routes/connections/JsonForm.tsx @@ -145,32 +145,52 @@ function NumberWidget({ function SelectWidget({ path, + valuePath, title, description, placeholder, - required, options, value, onChange, + defaultValue, + resetField, }: { path: string; + valuePath: string; title?: string; description?: string; placeholder?: string; - required?: boolean; options: Array<{ value: string; label: string }>; value: string; onChange: (e: React.ChangeEvent) => void; + defaultValue?: string; + resetField: (field: string) => any; }) { + useEffect(() => { + if (!value) { + if (defaultValue) { + // @ts-ignore + onChange({ target: { name: path, value: defaultValue } }); + } else { + // @ts-ignore + onChange({ target: { name: path, value: options[0].value } }); + } + } + }); + + const onChangeWrapper = (e: React.ChangeEvent) => { + resetField(valuePath); + onChange(e); + }; + return ( - + {title && {title}}