-
Notifications
You must be signed in to change notification settings - Fork 20
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
Show errors inline and prevent form submit when errors present. #348
Show errors inline and prevent form submit when errors present. #348
Conversation
I'm opening this up for review even though it's missing one piece that I originally considered as part of this effort, which is showing errors from the server inline on the form. |
'wcc-error': hasError, | ||
} ); | ||
return ( | ||
<div className={ classes }> |
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.
Optional. No need to assign to classes, just call classNames here
</Button> | ||
errors, | ||
} ) => { | ||
const hasError = !! errors.length; |
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.
!!
is kinda sketchy as far as good practices go
also, why not just pass in hasError
here directly since we never need the errors themselves in this component. I think the least info the components require, the better
Do you think Redux has a part to play in error handling? Would it simplify passing |
33de2d5
to
cc35ddd
Compare
I initially started with that, but then landed on this documentation (by way of reduxjs/redux#749) that made me rethink it. |
…ent, if errors exist for the field.
… the appropriate components. Also, “pop” off the packages/services field name before doing so.
…er than a full list of errors.
e8e644a
to
c8cdbb4
Compare
@allendav I can't reproduce your console errors. Can you try again now that I've rebased? |
@jeffstieler i don't get those errors anymore since the rebase. i do get this now: |
@allendav as we discussed, the |
Since we don't allow the user to submit invalid form data, maybe we should relax the adjustment value field so that it allows the user to input invalid characters. The way it works now is inconsistent with other text field above (zip, title, etc.). This would also hopefully resolve this issue: #188 When I tried editing the DB so that the value is a string, the field was highlighted, but there was no way to fix it because it wouldn't let me edit the field. Try adding a two-char string there. |
I'd rather we didn't
And I think that's appropriate for this field, since only numerics are allowed. Conceivably we could do the same for the ZIP code field as well, at least for USPS. But let's not make it easier for the user to enter bad data. But if we can't figure out a way to allow only certain characters in a field (like decimals) I guess we may have no choice but to relax this. |
@jeffstieler - I think so - captured key issue as a new issue here : #360 |
I think this is the key problem with our current implementation. I agree with @nabsul on this one, we should relax the EDIT: Let's just hash this out as part of #188. |
Requires https://github.com/Automattic/woocommerce-connect-server/pull/273 to test.
Fixes #206 and incorporates some error UI design from #306.
To test:
i:0
value tos:1:"a"