-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Conversation
@@ -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) : []; |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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
:)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
19aa552
to
8dd3f7f
Compare
Playground has been updated with this patch. Feedback welcome. http://mozilla-services.github.io/react-jsonschema-form/ |
Well, I think I'm gonna land this. r=me |
Simulate.submit(node); | ||
} catch(err) { | ||
// Ditto. | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 23978ea
r=? @leplatrem
/cc @kaihendry