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

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

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

Loading…
Cancel
Save