Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #176: Reset errors after submit & new data are entered. #177

Merged
merged 1 commit into from
Apr 29, 2016

Conversation

n1k0
Copy link
Collaborator

@n1k0 n1k0 commented Apr 28, 2016

@n1k0 n1k0 changed the title Fixes #176: Reset errors after submit & new data are rentered. Fixes #176: Reset errors after submit & new data are rentered. Apr 28, 2016
@n1k0 n1k0 changed the title Fixes #176: Reset errors after submit & new data are rentered. Fixes #176: Reset errors after submit & new data are entered. Apr 28, 2016
@@ -61,8 +61,7 @@ export default class Form extends Component {

onChange = (formData, options={validate: false}) => {
const liveValidate = this.props.liveValidate || options.validate;
const errors = liveValidate ? this.validate(formData) :
this.state.errors;
const errors = liveValidate ? this.validate(formData) : [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this reset every errors ?

It should reset the error of the field being changed, no ?

Copy link
Collaborator Author

@n1k0 n1k0 Apr 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that's a possibility but when liveValidate is not enabled, you basically have to resubmit the form to have errors rendered again. I could see a UX scenario where you discard errors field by field as soon as they're fixed, but that's one of the main purpose of liveValidate :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a checkbox in the playground to enable/disable live validation so we'll figure out how usable it this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added live validation toggler to the playground, you're definitely right wrt surprising behavior. Il revamp the patch.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 19aa552

- More consistent non-live validation behavior.
- Added live validation toggler to playground.
@n1k0 n1k0 force-pushed the 176-previous-errors-cleanup branch from 19aa552 to 8dd3f7f Compare April 29, 2016 09:38
@n1k0
Copy link
Collaborator Author

n1k0 commented Apr 29, 2016

Playground has been updated with this patch. Feedback welcome. http://mozilla-services.github.io/react-jsonschema-form/

@n1k0
Copy link
Collaborator Author

n1k0 commented Apr 29, 2016

Well, I think I'm gonna land this. r=me

@n1k0 n1k0 merged commit 249f177 into master Apr 29, 2016
@n1k0 n1k0 deleted the 176-previous-errors-cleanup branch April 29, 2016 10:20
Simulate.submit(node);
} catch(err) {
// Ditto.
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this? It seems like the submit just above should take care of this?

Copy link
Collaborator Author

@n1k0 n1k0 Apr 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha good catch, thanks :) this test has been revamped in the meanwhile though.

Edit: woops nope it hasn't. Will fix.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 23978ea

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

Successfully merging this pull request may close these issues.

3 participants