Skip to content
This repository has been archived by the owner on Jan 1, 2020. It is now read-only.

Feature: Reset globalErrors on field change #20

Open
jagged3dge opened this issue Jan 27, 2017 · 2 comments
Open

Feature: Reset globalErrors on field change #20

jagged3dge opened this issue Jan 27, 2017 · 2 comments

Comments

@jagged3dge
Copy link

Thank you for this awesome package! I'm using this in my project powering 4 forms of different sizes and I'm really happy how easily configurable and re-usable it is.

There's a wonderful option of reading globalErrors after form submission fails due to a backend error. It would be even better if this error could automatically reset if any of the internal field values changed.

Use case:
In a simple login form, I can read the globalErrors prop to check & handle the most common post-submit error: invalid credentials. This error, once shown, stays shown until the next time form submit succeeds, or results in a different error. Until then, the error message stays put. I believe it could be better UX if the error disappears (reset internally) as the user interacts with the form fields to change/correct their login credentials.

@danielberndt
Copy link
Collaborator

Ah, yes, I get what you mean.

How would you feel about being able something like a hasChanged to the renderForm options such that you could do

 renderForm: (FormContainer, children, {globalErrors, hasChanged, status}) => (
    <FormContainer>
      {globalErrors && !hasChanged ? (<div>{globalErrors}</div>) : null}
...

This would allow to customise the behaviour according to your needs which feels more in line with react-reform's philosophy of not being too opinionated.

@jagged3dge
Copy link
Author

Sounds perfect! 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants