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! |
| 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.
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
|
ctkochan22
left a comment
There was a problem hiding this comment.
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 🚀
|
| return this.props.formState.error || (typeof latestErrorMessage === 'string' ? latestErrorMessage : ''); | ||
| } | ||
|
|
||
| getFirstErroredInput() { |
There was a problem hiding this comment.
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.
this.state.erorrs is a typo ?
Details
This PR adds support for displaying
errorFieldscoming from the backend. Previously we could only display a backend error in the Onyx keyerrorsabove 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 Issuessection aboveTestssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*filesSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */displayNamepropertythisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)Avataris modified, I verified thatAvataris 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 Issuessection aboveTestssectionQA stepssectiontoggleReportand notonIconClick).src/languages/*filesSTYLE.md) were followedAvatar, I verified the components usingAvatarhave been tested & I retested again)/** comment above it */displayNamepropertythisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)Avataris modified, I verified thatAvataris working as expected in all cases)QA Steps
Screenshots
Web
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android