-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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: Resend magic code option behaves inconsistently #18632
Conversation
@danieldoglas @parasharrajat 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] |
@Pujan92 Tests are incomplete. Please fix that. |
@parasharrajat are you referring Offline tests here? |
All tests. |
1 similar comment
All tests. |
Screenshots🔲 iOS / native🔲 iOS / Safari🔲 MacOS / Desktop🔲 MacOS / ChromeScreen.Recording.2023-05-09.at.5.09.11.PM.mov🔲 Android / Chrome🔲 Android / native |
@parasharrajat I updated the tests, is it makes more sense now?
|
Please add the clicking the resend button should show the message below it. |
I think it is covered here
|
I noticed that the UI is moving up and down when the |
I think the text should use textSupporting and not red. We discussed that only form errors would get the full red text treatment (cc @JmillsExpensify @trjExpensify ) Also, for the text that says the link was sent, we should use the same dot indicator message style but the dot would be green and the message would be in textSupporting.
Is there a way to make it so that the form is anchored at the top and it just makes the form either get longer/shorter? Cc @grgia - not sure how we are laying out the sign up form but maybe that's not possible given the vertical alignment? |
Ok, I think we need to discuss that first. @danieldoglas Can you please hold this PR so that we don't count that in the merge PR timeline? |
@parasharrajat can bring that discussion on slack in the open-source channel, please? |
I can but I don't have the right context. It would be great if the design team can do that. Happy to help out along the way. cc: @grgia @shawnborton. |
@shawnborton @parasharrajat, yes we should be able to anchor the form to the top. I believe right now we're using some outdated flex styling from before when this page required keyboard avoiding. We can definitely fix that. |
@Pujan92 Do you want to continue the discussion here so that you are clear about the requirements? |
@parasharrajat @grgia I am not much clear with the point. how that will help to solve this issue( ![]() |
@parasharrajat and @grgia - little bump to keep this from getting stale. Thank you! |
Ok. I think we have waited enough on this issue.
IMO, this is not in the scope of this issue. Let's create another issue for this if this change is needed.
@Pujan92 Can you do this?
@Pujan92 We are saying that we fix the starting gap on the Form so that when content changes (error messages or Hope this is clear. If so, Can you please post a summary of changes you will do to acknowledge that you got it correctly? |
Ok.
@parasharrajat To confirm we need to take out the top empty View which is added here. That helps to not move content to upwards when the content gets changed. App/src/pages/signin/SignInPageLayout/SignInPageContent.js Lines 46 to 47 in 1ab36df
As per the comment, it seems that an empty View setup is added to make the content in a bit center. Without the dynamic top margin it may look a bit weird as the full bottom space will get emptied and looks like below. Screen.Recording.2023-05-23.at.11.45.13.AM.mov |
Yes you will have to make adjustments to keep vir vertically centred same as before but top gap should not change. |
Can we please remove HOLD from this PR and continue this? |
Apologies for the delay on this PR. I will be fully committed to this PR today. Please make sure that you have tested it completely before tagging me for another review. |
@Pujan92 Any take on this #18632 (comment)? |
I will check after an hour and update you on it. |
Thanks. |
@parasharrajat I am also seeing sometimes it diming 2 times for a single press. In this PR we are not touching that part but I am seeing recent changes being made to that |
Ok. Thanks. @Pujan92 can you confirm if this is present on staging or PROD? |
@parasharrajat Currently, in staging/prod we are hiding the link on the press so it won't be tested there, but if in the main branch I show the link all time as per this PR change then it can be reproduced. I believe it is not occurring due to my PR and something needs to be looked out within aaad.webm |
It does seem like an unrelated change or not an issue. we didn't add a new pressable it was present before. Apart from it, there is no issue. The rest of my testing is done. I will run another round now because we merged the main and complete this. It will be done in next hour. |
if (!inputValidateCodeRef.current || validateCode.length > 0 || linkSent) { | ||
return; | ||
} | ||
inputValidateCodeRef.current.clear(); | ||
}, [validateCode]); | ||
}, [validateCode, linkSent]); |
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.
It is hard to get my head around these hooks' logic. Can you please explain the purpose of this? IMO, it is not needed.
We want to clear the field when validateCode = ''
. So we don't need lintSent
here. LinkSet is set to
truein
resendValidationCodeand we are also doing
setValidateCode('')`, thus will be called and reset the code field.
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 understood why we are doing this. But this code is looking confusing. I got confused twice with this. At least, we can leave a comment here explain why?
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.
Ok, basically the issue persists when we clear the validateCode
the hook gets called and reset the linkSent
state variable which we set to true
in our resend function. To solve this I only found this way and did this. I will add a comment for it.
@@ -150,6 +147,8 @@ function BaseValidateCodeForm(props) { | |||
const resendValidateCode = () => { | |||
setTwoFactorAuthCode(''); | |||
setFormError({}); | |||
setValidateCode(''); | |||
inputValidateCodeRef.current.clear(); |
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.
Same, this can be removed because we have an effect above to handle this.
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.
Same here, Add a comment why if this change is necessary.
if (!validateCode) { | ||
return; | ||
} |
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.
We should revert this. If there is no validateCode, there is no need to clear it.
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.
Ok, in that case we need to add ignore comment for eslint as we are not going to add validateCode as a dependency.
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.
why can't we add the dependency here?
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.
We can add, I thought it will again create the same issue of linkSent but in particular this part it is relying on prevIsVisible && !props.isVisible
. I will add it.
@Pujan92 Bump. |
Updated. Plz review. |
@@ -150,6 +153,9 @@ function BaseValidateCodeForm(props) { | |||
const resendValidateCode = () => { | |||
setTwoFactorAuthCode(''); | |||
setFormError({}); | |||
setValidateCode(''); | |||
// Clearnig manually here instead relying on the hook bcoz of not allowing to reset the linkSent value |
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.
// Clearnig manually here instead relying on the hook bcoz of not allowing to reset the linkSent value | |
// We need to clear the input manually as we are preventing the hook which clears it from firing when linkSent is true. Clearing the input via state will trigger the changeText on Input which resets the link sent value but we need linkSent to show the `sent status` |
@@ -114,11 +116,12 @@ function BaseValidateCodeForm(props) { | |||
}, [props.account.requiresTwoFactorAuth, prevRequiresTwoFactorAuth]); | |||
|
|||
useEffect(() => { | |||
if (!inputValidateCodeRef.current || validateCode.length > 0) { | |||
// To avoid reset of linkSent from other hook we only clear the inputValidateCode when linkSent is false |
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.
// To avoid reset of linkSent from other hook we only clear the inputValidateCode when linkSent is false | |
// Avoid resetting the input when the link is sent to keep showing the sent status even when the input is empty. |
Awesome Thanks. Let me get this tested quickly. |
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.
Reviewer Checklist
- I have verified the author checklist is complete (all boxes are checked off).
- I verified the correct issue is linked in the
### Fixed Issues
section above - I verified testing steps are clear and they cover the changes made in this PR
- I verified the steps for local testing are in the
Tests
section - I verified the steps for Staging and/or Production testing are in the
QA steps
section - I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
- I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
- I verified the steps for local testing are in the
- I checked that screenshots or videos are included for tests on all platforms
- I included screenshots or videos for tests on all platforms
- I verified tests pass on all platforms & I tested again on:
- Android / native
- Android / Chrome
- iOS / native
- iOS / Safari
- MacOS / Chrome / Safari
- MacOS / Desktop
- If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
- I verified proper code patterns were followed (see Reviewing the code)
- I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e.
toggleReport
and notonIconClick
). - I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g.
myBool && <MyComponent />
. - I verified that comments were added to code that is not self explanatory
- I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
- I verified any copy / text shown in the product is localized by adding it to
src/languages/*
files and using the translation method - I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
- I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the
Waiting for Copy
label for a copy review on the original GH to get the correct copy. - I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
- I verified the JSDocs style guidelines (in
STYLE.md
) were followed
- I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e.
- If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
- I verified that this PR follows the guidelines as stated in the Review Guidelines
- I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like
Avatar
, I verified the components usingAvatar
have been tested & I retested again) - I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
- I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
- If a new component is created I verified that:
- A similar component doesn't exist in the codebase
- All props are defined accurately and each prop has a
/** comment above it */
- The file is named correctly
- The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
- The only data being stored in the state is data necessary for rendering and nothing else
- For Class Components, any internal methods passed to components event handlers are bound to
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor) - Any internal methods bound to
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
) - All JSX used for rendering exists in the render method
- The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
- If any new file was added I verified that:
- The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
- If a new CSS style is added I verified that:
- A similar style doesn't already exist
- The style can't be created with an existing StyleUtils function (i.e.
StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)
- If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
- If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like
Avatar
is modified, I verified thatAvatar
is working as expected in all cases) - If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
- If a new page is added, I verified it's using the
ScrollView
component to make it scrollable when more elements are added to the page. - If the
main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps. - I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.
cc: @danieldoglas
🎀 👀 🎀 C+ reviewed
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.
LGTM
✋ 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/danieldoglas in version: 1.3.29-0 🚀
|
🚀 Deployed to production by https://github.com/luacmartins in version: 1.3.29-11 🚀
|
Details
Changes applied to the magic code screen which shows the resend magic code link all the time and success/error messages will be shown below it.
Fixed Issues
$ #17864
PROPOSAL: #17864 (comment)
Tests
Didn't receive a magic code?
remains available all the timea. Error on invalid magic code
b. Success message
Magic code sent
on click ofDidn't receive a magic code?
linkc. Error on maximum magic code sent attempts
Offline tests
N/A
QA Steps
Didn't receive a magic code?
remains available all the timea. Error on invalid magic code
b. Success message
Magic code sent
on click ofDidn't receive a magic code?
linkc. Error on maximum magic code sent attempts
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
Screen.Recording.2023-05-09.at.1.46.25.PM.mp4
Mobile Web - Chrome
Mobile Web - Safari
Simulator.Screen.Recording.-.iPhone.14.-.2023-05-09.at.14.11.14.mp4
Desktop
Screen.Recording.2023-05-09.at.2.07.18.PM.mov
iOS
Simulator.Screen.Recording.-.iPhone.14.-.2023-05-09.at.14.03.12.mp4
Android