-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Fix Form useEffect #20091
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
Fix Form useEffect #20091
Conversation
|
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
|
@rushatgabhane @MonilBhavsar One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
Bump for review |
MonilBhavsar
left a comment
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.
Code looks good to me!
@rushatgabhane would like to get your help in review and checklist
Reviewer Checklist
Screenshots/VideosMobile Web - ChromeMobile Web - Safari |
src/components/Form.js
Outdated
|
|
||
| const errorMessage = useMemo(() => { | ||
| const latestErrorMessage = ErrorUtils.getLatestErrorMessage(props.formState); | ||
| return props.formState.error || (typeof latestErrorMessage === 'string' ? latestErrorMessage : ''); |
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.
NAB: I think there's a typo here? There is no such field called formState.error
It's formState.errors, right? (notice the "s")
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.
Yea, you're right. Fixed!
@luacmartins the app crash when I clicked submit in step 11
|
|
It's consistently reproducible. Screen.Recording.2023-06-08.at.01.39.18.mov |
|
Oh interesting. I did not see that while testing. Let me take a look |
|
I think it's because of the last commit. The For |
|
Yea, it's the last commit that's causing it. We can actually remove that entirely, since we pass |
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.
- Should we dismiss the server error when the focused input is changed? I think no because the user didn't fix the server error, and the error message disappeared making it harder to fix the error.
- I'm able to submit the form without accepting the Terms of Service.
Screen.Recording.2023-06-08.at.08.42.48.mov
|
Oops, nice find 👍
I would also say, no |
|
I'll get back to this tomorrow |
|
|
Updated! |
|
Bumping for reviews! |
|
Bump for reviews! |
|
@rushatgabhane could you please review first |
rushatgabhane
left a comment
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.
@MonilBhavsar LGTM
|
We did not find an internal engineer to review this PR, trying to assign a random engineer to #19923... Please reach out for help on Slack if no one gets assigned! |
|
✋ 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 https://github.com/luacmartins in version: 1.3.29-0 🚀
|
|
🚀 Deployed to production by https://github.com/luacmartins in version: 1.3.29-11 🚀
|






Details
We need to skip Form validation on initial render to align with the old bahavior of
componentDidUpdate. This prevents a bug in the following scenario:Formunmounts andReimbursementAccountLoadingIndicatormountsReimbursementAccountLoadingIndicatorunmounts andFormremounts with the erroronValidateonValidateruns, which in turn callsFormActions.setErrorsandFormActions.setErrorFieldsimmediately clearing server errors.We still want to clear errors on validation, so the solution is to align the call to useEffect with the behavior of componentDidMount by using a ref to keep track of Form's initial render.
Fixed Issues
$ #19923
Tests
+ > New workspaceSettings > Workspaces > Bank accountConnect online with PlaidChaseuser_goodandpass_goodas the credentialsRouting numberinput and click outside of the inputSettings > PreferencesOffline tests
N/A
QA Steps
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly 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)ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Web
web.mov
Mobile Web - Chrome
chrome.mov
Mobile Web - Safari
safari.mov
Desktop
desktop.mov
iOS
ios.mov
Android
android.mov