import type { FieldValues, Path, UseFormReturn } from "react-hook-form"; export const focusFirstInputFormError = (form: UseFormReturn) => { const errors = form.formState.errors; const firstKey = Object.keys(errors)[0] as keyof T | undefined; if (firstKey) { form.setFocus(firstKey as Path); } return; };