fix(striker-ui): remove disableAutocomplete from formik utils

main
Tsu-ba-me 11 months ago
parent bd65517449
commit ddece3750d
  1. 15
      striker-ui/components/ManageMailServer/AddMailServerForm.tsx
  2. 13
      striker-ui/hooks/useFormikUtils.ts
  3. 5
      striker-ui/types/FormikUtils.d.ts

@ -26,13 +26,8 @@ const AddMailServerForm: FC<AddMailServerFormProps> = (props) => {
[mailServerUuid],
);
const {
disableAutocomplete,
disabledSubmit,
formik,
formikErrors,
handleChange,
} = useFormikUtils<MailServerFormikValues>({
const { disabledSubmit, formik, formikErrors, handleChange } =
useFormikUtils<MailServerFormikValues>({
initialValues: previousFormikValues ?? {
[msUuid]: {
address: '',
@ -206,8 +201,8 @@ const AddMailServerForm: FC<AddMailServerFormProps> = (props) => {
<UncontrolledInput
input={
<OutlinedInputWithLabel
disableAutofill
id={usernameChain}
inputProps={disableAutocomplete()}
label="Server username"
name={usernameChain}
onChange={handleChange}
@ -220,8 +215,8 @@ const AddMailServerForm: FC<AddMailServerFormProps> = (props) => {
<UncontrolledInput
input={
<OutlinedInputWithLabel
disableAutofill
id={passwordChain}
inputProps={disableAutocomplete()}
label="Server password"
name={passwordChain}
onChange={handleChange}
@ -236,8 +231,8 @@ const AddMailServerForm: FC<AddMailServerFormProps> = (props) => {
<UncontrolledInput
input={
<OutlinedInputWithLabel
disableAutofill
id={confirmPasswordChain}
inputProps={disableAutocomplete()}
label="Confirm password"
name={confirmPasswordChain}
onChange={handleChange}

@ -1,4 +1,3 @@
import { OutlinedInputProps } from '@mui/material';
import { FormikConfig, FormikValues, useFormik } from 'formik';
import { isEqual, isObject } from 'lodash';
import { useCallback, useMemo } from 'react';
@ -41,17 +40,6 @@ const useFormikUtils = <Values extends FormikValues = FormikValues>(
[formik.initialValues, formik.values],
);
const disableAutocomplete = useCallback(
(overwrite?: Partial<OutlinedInputProps>): OutlinedInputProps => ({
readOnly: true,
onFocus: (event) => {
event.target.readOnly = false;
},
...overwrite,
}),
[],
);
const debounceHandleChange = useMemo(
() => debounce(formik.handleChange),
[formik.handleChange],
@ -75,7 +63,6 @@ const useFormikUtils = <Values extends FormikValues = FormikValues>(
);
return {
disableAutocomplete,
disabledSubmit,
formik,
formikErrors,

@ -12,11 +12,6 @@ type FormikSubmitHandler<Values extends FormikValues> =
import('formik').FormikConfig<Values>['onSubmit'];
type FormikUtils<Values extends FormikValues> = {
disableAutocomplete: (
overwrite?: Partial<
import('../components/OutlinedInput').OutlinedInputProps
>,
) => import('../components/OutlinedInput').OutlinedInputProps;
disabledSubmit: boolean;
formik: Formik<Values>;
formikErrors: Messages;

Loading…
Cancel
Save