-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Support displaying backend errors in Form #11465
Conversation
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
<FormAlertWithSubmitButton | ||
buttonText={this.props.submitButtonText} | ||
isAlertVisible={_.size(this.state.errors) > 0 || Boolean(this.props.formState.error)} | ||
isLoading={this.props.formState.isLoading} | ||
message={this.props.formState.error} | ||
message={_.isEmpty(this.props.formState.errorFields) ? this.getErrorMessage() : null} |
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 figured I should add this check here to avoid displaying a duplicate message on both the error field above the submit button and below the errored input. Instead, we will display the fixTheErrors
message and the field error message below the input.
@youssef-lr What are the testing steps? If not having JS Console errors is the only test, this will probably never pass local testing since there is always SOME kind of JS console error going on in local dev 😅 |
Hey Scott! I just added [WIP] to the title, I'm waiting for feedback on the linked issue before I can finalize this PR and then I'll add tests. |
Hey @youssef-lr, I am going to drop myself from this PR so it isn't beaming its angry red text at me in my K2. Feel free to add me back when it's no longer an WIP and ready for review. |
No worries @deetergp! |
hey @ctkochan22 - I hope you don't mind reviewing this and testing it along with your Web-E PR! I didn't know what to put in the test steps as we're not actively using |
Yeah there doesn't seem to be a way to test for now. We should simply do regression testing. Can you add regression testing? Like pick a couple forms, and make sure error validations show up normally? |
We shoudl update the .md like botify mentions |
I'll test and merge, but please also move regression testing to QA so they'll have a chance to test it again |
Done @ctkochan22. |
The Contributor+ will copy/paste it into a new comment and complete it after the author checklist is completed
|
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.
Please add clear QA regression tests as well before this gets deployed please!
@ctkochan22 looks like this was merged without the checklist test passing. Please add a note explaining why this was done and remove the |
Checklist filled out |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by @ctkochan22 in version: 1.2.30-0 🚀
|
🚀 Deployed to staging by @ctkochan22 in version: 1.2.30-0 🚀
|
🚀 Deployed to production by @luacmartins in version: 1.2.30-0 🚀
|
@@ -90,6 +93,17 @@ class Form extends React.Component { | |||
return this.props.formState.error || (typeof latestErrorMessage === 'string' ? latestErrorMessage : ''); | |||
} | |||
|
|||
getFirstErroredInput() { |
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.
Just come across this randomly but this is missing a JSDoc and should have an @returns
return; | ||
} | ||
|
||
return _.first(_.keys(hasStateErrors ? this.state.erorrs : this.props.formState.errorFields)); |
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.
this.state.erorrs
is a typo ?
Details
This PR adds support for displaying
errorFields
coming from the backend. Previously we could only display a backend error in the Onyx keyerrors
above the submit buttons. This will enable us to display backend errors under the relevant inputs.Fixed Issues
$ #11267
Tests
Regression test: let's test one of the forms that uses Form and make sure everything works properly.
Testing error displayed under a field with a backend error (must be tested with https://github.com/Expensify/Web-Expensify/pull/35548)
<b></b>
and click Save.
3. Clicking on 'fix the errors' should focus on the input of the name of the workspace.PR Review Checklist
Contributor (PR Author) Checklist
### Fixed Issues
section aboveTests
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
filesSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
displayName
propertythis
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)PR Reviewer Checklist
The Contributor+ will copy/paste it into a new comment and complete it after the author checklist is completed
### Fixed Issues
section aboveTests
sectionQA steps
sectiontoggleReport
and notonIconClick
).src/languages/*
filesSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
have been tested & I retested again)/** comment above it */
displayName
propertythis
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)QA Steps
Screenshots
Web
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android