final-form / final-form-focus

🏁 Final Form "decorator" that will attempt to apply focus to the first field with an error upon an attempted form submission
MIT License
83 stars 15 forks source link

2 form on page, focus working incorrect #8

Open DragorWW opened 5 years ago

DragorWW commented 5 years ago

example: https://codesandbox.io/s/818ov6pok0

case:

What is the current behavior?

input in first form get focus

What is the expected behavior?

input in last form get focus

tylim88 commented 5 years ago

having the same issue, but mine is only one form

it focuses on the error that you focus last, it seems your example also has similar behavior

ArtyomResh commented 5 years ago

That happens because createDecorator search invalid input with specific name in all forms:

and focuses on first its get:

Use getFormInputs to search for invalid input only in specific form, here is example: https://codesandbox.io/embed/react-final-form-focus-on-first-error-hvzhm

Yankovsky commented 5 years ago

@DragorWW @tylim88 ^

ArtyomResh commented 4 years ago

@erikras Hi! Can you please approve my PR, that corrects this misconception in the documentation?