-
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
Fix Form useEffect #20091
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 |
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
// eslint-disable-next-line react-hooks/exhaustive-deps -- we just want to revalidate the form on update if the preferred locale changed on another device so that errors get translated | ||
}, [props.preferredLocale]); | ||
|
||
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 |
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:Form
unmounts andReimbursementAccountLoadingIndicator
mountsReimbursementAccountLoadingIndicator
unmounts andForm
remounts with the erroronValidate
onValidate
runs, which in turn callsFormActions.setErrors
andFormActions.setErrorFields
immediately 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 workspace
Settings > Workspaces > Bank account
Connect online with Plaid
Chase
user_good
andpass_good
as the credentialsRouting number
input and click outside of the inputSettings > Preferences
Offline tests
N/A
QA Steps
Same as tests
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
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)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
web.mov
Mobile Web - Chrome
chrome.mov
Mobile Web - Safari
safari.mov
Desktop
desktop.mov
iOS
ios.mov
Android
android.mov