Skip to content

Commit

Permalink
Remove null option from select widget
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jbeisen committed Dec 14, 2023
1 parent 2e513f0 commit 2c9454f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions arroyo-console/src/routes/connections/JsonForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ function SelectWidget({
value: string;
onChange: (e: React.ChangeEvent<any>) => void;
}) {
useEffect(() => {
if (!value) {
onChange({ target: { name: path, value: options[0].value } });
}
});

return (
<FormControl isRequired={required}>
{title && <FormLabel>{title}</FormLabel>}
Expand Down Expand Up @@ -470,7 +476,6 @@ export function FormInner({
key={key}
title={property.title || key}
description={property.description}
placeholder="Select an option"
required={schema.required?.includes(key)}
options={property.enum.map(value => ({
value: value!.toString(),
Expand Down Expand Up @@ -551,7 +556,6 @@ export function FormInner({
<Stack p={4}>
<SelectWidget
path={typeKey}
placeholder="Select an option"
description={property.description}
required={schema.required?.includes(key)}
options={property.oneOf.map(oneOf => ({
Expand Down

0 comments on commit 2c9454f

Please sign in to comment.