diff --git a/apps/console/src/components/form/PeopleSelectField.tsx b/apps/console/src/components/form/PeopleSelectField.tsx index a72a75cfb..3a6f96b1e 100644 --- a/apps/console/src/components/form/PeopleSelectField.tsx +++ b/apps/console/src/components/form/PeopleSelectField.tsx @@ -10,6 +10,7 @@ type Props = { name: string; label?: string; error?: string; + optional?: boolean; } & ComponentProps; export function PeopleSelectField({ @@ -27,6 +28,7 @@ export function PeopleSelectField({ control={control} name={props.name} disabled={props.disabled} + optional={props.optional} /> @@ -34,7 +36,7 @@ export function PeopleSelectField({ } function PeopleSelectWithQuery( - props: Pick + props: Pick ) { const { __ } = useTranslate(); const { name, organizationId, control } = props; @@ -51,12 +53,15 @@ function PeopleSelectWithQuery( id={name} variant="editor" placeholder={__("Select an owner")} - onValueChange={field.onChange} + onValueChange={(value) => field.onChange(value === "__NONE__" ? null : value)} key={people?.length.toString() ?? "0"} {...field} className="w-full" - value={field.value ?? ""} + value={field.value ?? (props.optional ? "__NONE__" : "")} > + {props.optional && ( + + )} {people?.map((p) => (