Summary
To enhance the UX and accessibility of the form hook we should be able to add the option to auto focus on validation. e.g.: Whenever there is a substantial amount of input fields present the user should be able to quickly pin point any errors that were made during an application process.
This will also increase the accessibility of the form since a user with a screen reader wont have to tab to the missing field and will be able to adjust any mistakes in moments notice.
For example implementations:
ant-design/ant-design#45739
We should see if this feature should be optional or not via e.g.:
<Form focusOnError>
xxx
</Form>
A hacky solution with the current version is something like:
const error = snapshot.get(form).error.children
Object.keys(errors).forEach((error) => {
const el = document.getElementById(form.fields[error].name)
el.focus()
}
For more information about the accessibility implications:
https://www.w3.org/TR/UNDERSTANDING-WCAG20/minimize-error-identified.html