diff --git a/client/src/Components/inputs/forms/FormAutoCompleteField.tsx b/client/src/Components/inputs/forms/FormAutoCompleteField.tsx index 6c1a4fd94..3af48efb3 100644 --- a/client/src/Components/inputs/forms/FormAutoCompleteField.tsx +++ b/client/src/Components/inputs/forms/FormAutoCompleteField.tsx @@ -19,6 +19,7 @@ interface FormAutocompleteProps["filterOptions"]; getOptionDisabled?: AutocompleteProps["getOptionDisabled"]; + disableClearable?: boolean; } export const FormAutocompleteField = < @@ -31,6 +32,7 @@ export const FormAutocompleteField = < placeholder, filterOptions, getOptionDisabled, + disableClearable, }: FormAutocompleteProps) => { const { control } = useFormContext(); return ( @@ -44,12 +46,14 @@ export const FormAutocompleteField = < isOptionEqualToValue={(option, value) => option.id === value.id} value={options.find((o) => o.id === field.value) ?? null} onChange={(_: unknown, newValue: O | null) => { + if (newValue === null && disableClearable) return; field.onChange(newValue?.id ?? ""); }} fieldLabel={fieldLabel} placeholder={placeholder} filterOptions={filterOptions} getOptionDisabled={getOptionDisabled} + disableClearable={disableClearable} error={!!fieldState.error} helperText={fieldState.error?.message ?? ""} /> diff --git a/client/src/Pages/CreateMonitor/index.tsx b/client/src/Pages/CreateMonitor/index.tsx index 380329c4b..921f3deb3 100644 --- a/client/src/Pages/CreateMonitor/index.tsx +++ b/client/src/Pages/CreateMonitor/index.tsx @@ -811,6 +811,7 @@ const CreateMonitorPage = () => { filterIntervalOptions(options, inputValue) } getOptionDisabled={(option) => option.id < MIN_MONITOR_INTERVAL_MS} + disableClearable /> } />