Skip to content

Commit 2c9454f

Browse files
committed
Remove null option from select widget
This solves a problem with formik not properly handling changing enums to null. This changes the select widget to always start on the first option.
1 parent 2e513f0 commit 2c9454f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

arroyo-console/src/routes/connections/JsonForm.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ function SelectWidget({
162162
value: string;
163163
onChange: (e: React.ChangeEvent<any>) => void;
164164
}) {
165+
useEffect(() => {
166+
if (!value) {
167+
onChange({ target: { name: path, value: options[0].value } });
168+
}
169+
});
170+
165171
return (
166172
<FormControl isRequired={required}>
167173
{title && <FormLabel>{title}</FormLabel>}
@@ -470,7 +476,6 @@ export function FormInner({
470476
key={key}
471477
title={property.title || key}
472478
description={property.description}
473-
placeholder="Select an option"
474479
required={schema.required?.includes(key)}
475480
options={property.enum.map(value => ({
476481
value: value!.toString(),
@@ -551,7 +556,6 @@ export function FormInner({
551556
<Stack p={4}>
552557
<SelectWidget
553558
path={typeKey}
554-
placeholder="Select an option"
555559
description={property.description}
556560
required={schema.required?.includes(key)}
557561
options={property.oneOf.map(oneOf => ({

0 commit comments

Comments
 (0)