Fix modal can not focus second input bug

This commit is contained in:
2024-03-01 16:35:49 +08:00
parent e2dfe89d04
commit 3b11b262b9
8 changed files with 178 additions and 85 deletions

View File

@@ -105,24 +105,30 @@ const SignIn = () => {
twoFactorForm.resetFields()
void modal.confirm({
title: '双因素验证',
getContainer: false,
centered: true,
footer: (_, { OkBtn, CancelBtn }) => (
<>
<OkBtn />
<CancelBtn />
</>
),
content: (
<>
<AntdForm form={twoFactorForm}>
<AntdForm
form={twoFactorForm}
ref={(ref) => {
setTimeout(() => {
ref?.getFieldInstance('twoFactorCode').focus()
}, 50)
}}
>
<AntdForm.Item
name={'twoFactorCode'}
label={'验证码'}
style={{ marginTop: 10 }}
rules={[{ required: true, len: 6 }]}
>
<AntdInput
showCount
maxLength={6}
ref={(input) => {
input?.focus()
}}
/>
<AntdInput showCount maxLength={6} />
</AntdForm.Item>
</AntdForm>
</>