Prevent clearing monitor intervals
This commit is contained in:
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;
|
placeholder?: string;
|
||||||
filterOptions?: AutocompleteProps<O, false, false, false>["filterOptions"];
|
filterOptions?: AutocompleteProps<O, false, false, false>["filterOptions"];
|
||||||
getOptionDisabled?: AutocompleteProps<O, false, false, false>["getOptionDisabled"];
|
getOptionDisabled?: AutocompleteProps<O, false, false, false>["getOptionDisabled"];
|
||||||
|
disableClearable?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const FormAutocompleteField = <
|
export const FormAutocompleteField = <
|
||||||
@@ -31,6 +32,7 @@ export const FormAutocompleteField = <
|
|||||||
placeholder,
|
placeholder,
|
||||||
filterOptions,
|
filterOptions,
|
||||||
getOptionDisabled,
|
getOptionDisabled,
|
||||||
|
disableClearable,
|
||||||
}: FormAutocompleteProps<T, O>) => {
|
}: FormAutocompleteProps<T, O>) => {
|
||||||
const { control } = useFormContext<T>();
|
const { control } = useFormContext<T>();
|
||||||
return (
|
return (
|
||||||
@@ -44,12 +46,14 @@ export const FormAutocompleteField = <
|
|||||||
isOptionEqualToValue={(option, value) => option.id === value.id}
|
isOptionEqualToValue={(option, value) => option.id === value.id}
|
||||||
value={options.find((o) => o.id === field.value) ?? null}
|
value={options.find((o) => o.id === field.value) ?? null}
|
||||||
onChange={(_: unknown, newValue: O | null) => {
|
onChange={(_: unknown, newValue: O | null) => {
|
||||||
|
if (newValue === null && disableClearable) return;
|
||||||
field.onChange(newValue?.id ?? "");
|
field.onChange(newValue?.id ?? "");
|
||||||
}}
|
}}
|
||||||
fieldLabel={fieldLabel}
|
fieldLabel={fieldLabel}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
filterOptions={filterOptions}
|
filterOptions={filterOptions}
|
||||||
getOptionDisabled={getOptionDisabled}
|
getOptionDisabled={getOptionDisabled}
|
||||||
|
disableClearable={disableClearable}
|
||||||
error={!!fieldState.error}
|
error={!!fieldState.error}
|
||||||
helperText={fieldState.error?.message ?? ""}
|
helperText={fieldState.error?.message ?? ""}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -811,6 +811,7 @@ const CreateMonitorPage = () => {
|
|||||||
filterIntervalOptions(options, inputValue)
|
filterIntervalOptions(options, inputValue)
|
||||||
}
|
}
|
||||||
getOptionDisabled={(option) => option.id < MIN_MONITOR_INTERVAL_MS}
|
getOptionDisabled={(option) => option.id < MIN_MONITOR_INTERVAL_MS}
|
||||||
|
disableClearable
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in new issue
Block a user