Prevent clearing monitor intervals

This commit is contained in:
fabiangigler committed 2026-09-13 20:28:27 +02:00
1 parent 4bb366f5ab
commit 5da472da14
2 files changed
+5

No files matched your search

@@ -19,6 +19,7 @@ interface FormAutocompleteProps<T extends FieldValues, O extends AutocompleteOpt
placeholder?: string;
filterOptions?: AutocompleteProps<O, false, false, false>["filterOptions"];
getOptionDisabled?: AutocompleteProps<O, false, false, false>["getOptionDisabled"];
disableClearable?: boolean;
}
export const FormAutocompleteField = <
@@ -31,6 +32,7 @@ export const FormAutocompleteField = <
placeholder,
filterOptions,
getOptionDisabled,
disableClearable,
}: FormAutocompleteProps<T, O>) => {
const { control } = useFormContext<T>();
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 ?? ""}
/>
+1
View File
@@ -811,6 +811,7 @@ const CreateMonitorPage = () => {
filterIntervalOptions(options, inputValue)
}
getOptionDisabled={(option) => option.id < MIN_MONITOR_INTERVAL_MS}
disableClearable
/>
}
/>