Open ThinhNguyenHoang opened 2 years ago
Sup! Check your chrome console for a warning that starts like this:
Warning: [antd: Input] When Input is focused, dynamic add or remove prefix / suffix will make it lose focus caused by dom structure change...
If so, the link in the message basically tells you to set default prefix/suffix (the element antd uses to render input validation) to your Input. I just left it blank, the problem is gone :
<Input name="password" placeholder="Password" suffix />
Hello! Have similar issue here, but do not see any warning message like mentioned above by @elghst.
I think i might find reason for that. It is reproducible on latest for today antd@4.21.3
version but not reproduced on 4.1.0 which is set as dependency here in formik-antd
codesandbox example.
It seems input is rerendered when validation error is displayed/hided.
Here is issue reproduced example on codesandbox.
How to reproduce:
How to fix:
@andrii-muntian-p24 This is an issue with antd but in your case adding hasFeedback={false} to the FormItem or adding showCount to the TextArea should fix the issue.
Hello, For some reason the form input loses focus when the field validity change (from Invalid to invalid and vice versa) . I don't know if this is the default behavior but it feels annoying as a user (require additional mouse click to re-enter the form) .
Code: `import { Button, Space } from 'antd'; import React from 'react'; import * as Yup from 'yup' import { Formik } from 'formik'; import { Form, FormItem, Input} from 'formik-antd';
const validationSchema = Yup.object({ test: Yup.string().required("required") }) const TestPage = () => ( <> <Formik onSubmit={(val) => console.log("values", val)} initialValues={{ test: "" }} validationSchema={validationSchema}> {({ values }) => { return