Html Label (in testing contexts) and a11y behavior not optimal
See original GitHub issueCan you elaborate a bit which labels you mean exactly?
Sure, here’s a forked example of your CodeSandbox: https://codesandbox.io/s/y257p4l8z9
Edit: as a counter-example, look at antd’s own CodeSandbox to see how the DOM differs: https://codesandbox.io/s/kw79qx5w15
The label element for [name=userName] does not have a for="userName", which breaks things like react-testing-library’s getByLabelText and forces me to fallback to less optimal methods for finding and filling inputs, and breaks some browser / a11y behavior.
I have a feeling this is some sort of props issue, but honestly just have not had time to examine further.
(P.S. Thanks for making this!)
_Originally posted by @joshsmith in https://github.com/jannikbuschke/formik-antd/pull/23#issuecomment-488612356_
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:14 (9 by maintainers)

Top Related StackOverflow Question
Ill keep this open to also monitor the ant design issue.
It should not require setting htmlFor. Standard AntD works with just a FormItem having a name. This package just needs to pass the name field onto the FormItem as @ghola said.