From 16b3c580e6e9ea1fa5d52a111ebcb95180cd6392 Mon Sep 17 00:00:00 2001 From: Charles Zhao Date: Mon, 13 Mar 2023 11:07:24 +0800 Subject: [PATCH] fix(console): add auto focus to inputs in ac profile modals (#3339) --- .../Profile/containers/BasicUserInfoUpdateModal/index.tsx | 3 ++- .../src/pages/Profile/containers/ChangePasswordModal/index.tsx | 2 ++ .../src/pages/Profile/containers/LinkEmailModal/index.tsx | 2 ++ .../src/pages/Profile/containers/VerifyPasswordModal/index.tsx | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/console/src/pages/Profile/containers/BasicUserInfoUpdateModal/index.tsx b/packages/console/src/pages/Profile/containers/BasicUserInfoUpdateModal/index.tsx index 0223597ca..723f9eaf9 100644 --- a/packages/console/src/pages/Profile/containers/BasicUserInfoUpdateModal/index.tsx +++ b/packages/console/src/pages/Profile/containers/BasicUserInfoUpdateModal/index.tsx @@ -42,7 +42,6 @@ const BasicUserInfoUpdateModal = ({ field, value: initialValue, isOpen, onClose handleSubmit, setValue, reset, - setError, formState: { errors, isSubmitting }, } = useForm({ reValidateMode: 'onBlur' }); @@ -130,6 +129,8 @@ const BasicUserInfoUpdateModal = ({ field, value: initialValue, isOpen, onClose !!value || t('errors.required_field_missing', { field: t(`profile.settings.${field}`) }), })} + // eslint-disable-next-line jsx-a11y/no-autofocus + autoFocus placeholder={getInputPlaceholder()} errorMessage={errors[field]?.message} size="large" diff --git a/packages/console/src/pages/Profile/containers/ChangePasswordModal/index.tsx b/packages/console/src/pages/Profile/containers/ChangePasswordModal/index.tsx index 0fe1ccb35..9ae4d2247 100644 --- a/packages/console/src/pages/Profile/containers/ChangePasswordModal/index.tsx +++ b/packages/console/src/pages/Profile/containers/ChangePasswordModal/index.tsx @@ -104,6 +104,8 @@ const ChangePasswordModal = () => { message: t('errors.password_pattern_error'), }, })} + // eslint-disable-next-line jsx-a11y/no-autofocus + autoFocus type={showPassword ? 'text' : 'password'} errorMessage={errors.newPassword?.message} suffix={ diff --git a/packages/console/src/pages/Profile/containers/LinkEmailModal/index.tsx b/packages/console/src/pages/Profile/containers/LinkEmailModal/index.tsx index f972806ac..4c8e6387c 100644 --- a/packages/console/src/pages/Profile/containers/LinkEmailModal/index.tsx +++ b/packages/console/src/pages/Profile/containers/LinkEmailModal/index.tsx @@ -61,6 +61,8 @@ const LinkEmailModal = () => { currentEmail !== value || t('profile.link_account.identical_email_address'), })} + // eslint-disable-next-line jsx-a11y/no-autofocus + autoFocus errorMessage={errors.email?.message} size="large" onKeyDown={(event) => { diff --git a/packages/console/src/pages/Profile/containers/VerifyPasswordModal/index.tsx b/packages/console/src/pages/Profile/containers/VerifyPasswordModal/index.tsx index 7e4549b1c..479bcf925 100644 --- a/packages/console/src/pages/Profile/containers/VerifyPasswordModal/index.tsx +++ b/packages/console/src/pages/Profile/containers/VerifyPasswordModal/index.tsx @@ -76,6 +76,8 @@ const VerifyPasswordModal = () => { >