@@ -25,7 +25,6 @@ export type ComboboxFieldProps<
2525 name : TName
2626 control : Control < TFieldValues >
2727 onChange ?: ( value : string | null | undefined ) => void
28- disabled ?: boolean
2928} & ComboboxBaseProps
3029
3130export function ComboboxField <
@@ -38,22 +37,37 @@ export function ComboboxField<
3837 label = capitalize ( name ) ,
3938 required,
4039 onChange,
41- disabled,
40+ allowArbitraryValues,
41+ placeholder,
42+ // Intent is to not show both a placeholder and a description, while still having good defaults; prefer a description to a placeholder
43+ /*
44+ * If description is provided, use it.
45+ * If not, but a placeholder is provided, the default description should be undefined.
46+ * If no placeholder is provided and arbitrary values are allowed, the default description should be 'Select an option or enter a custom value'.
47+ * If no placeholder is provided and arbitrary values are not allowed, the default description should be 'Select an option'.
48+ */
49+ description = placeholder
50+ ? undefined
51+ : allowArbitraryValues
52+ ? 'Select an option or enter a custom value'
53+ : 'Select an option' ,
4254 ...props
4355} : ComboboxFieldProps < TFieldValues , TName > ) {
4456 const { field, fieldState } = useController ( { name, control, rules : { required } } )
4557 return (
4658 < div className = "max-w-lg" >
4759 < Combobox
48- isDisabled = { disabled }
4960 label = { label }
61+ placeholder = { placeholder }
62+ description = { description }
5063 required = { required }
5164 selected = { field . value || null }
5265 hasError = { fieldState . error !== undefined }
5366 onChange = { ( value ) => {
5467 field . onChange ( value )
5568 onChange ?.( value )
5669 } }
70+ allowArbitraryValues = { allowArbitraryValues }
5771 { ...props }
5872 />
5973 < ErrorMessage error = { fieldState . error } label = { label } />
0 commit comments