Skip to content
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

[HOLD for payment 2023-06-29] [$2000] Web - Login - 2FA Input field not focused when proceed from magic code page #19711

Closed
4 of 6 tasks
kavimuru opened this issue May 27, 2023 · 58 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor

Comments

@kavimuru
Copy link

kavimuru commented May 27, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

Precondition - User has setup a 2FA to log into account

  1. Open https://staging.new.expensify.com/

  2. Input email for account from the precondition

  3. Click "Continue"
    4.Input magic code

  4. Click "Continue"

  5. Press digits in the keyboard

Expected Result:

After user proceeds to authenticator code input page - the input field is focused and user can instantly type the code

Actual Result:

After user proceeds to authenticator code input page - the input field is NOT focused and user has to additionally click on it to set focus

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.19-2
Reproducible in staging?: y
Reproducible in production?: y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation

Bug6069872_Recording__606.mp4

Expensify/Expensify Issue URL:
Issue reported by: Applause internal team
Slack conversation:

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0145b8fd18db4b7dff
  • Upwork Job ID: 1663365147022503936
  • Last Price Increase: 2023-06-14
@kavimuru kavimuru added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels May 27, 2023
@melvin-bot
Copy link

melvin-bot bot commented May 27, 2023

Triggered auto assignment to @kadiealexander (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot
Copy link

melvin-bot bot commented May 27, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@PrashantMangukiya
Copy link
Contributor

Proposal

Posting proposal early as per new guidelines

Please re-state the problem that we are trying to solve in this issue.

Web - Login - 2FA Input field not focused when proceed from magic code page

What is the root cause of that problem?

We are rendering magic code and 2FA input conditionally via code block shown below.

{this.props.account.requiresTwoFactorAuth ? (
<View style={[styles.mv3]}>
<MagicCodeInput
autoComplete={this.props.autoComplete}
ref={(el) => (this.input2FA = el)}
label={this.props.translate('common.twoFactorCode')}
name="twoFactorAuthCode"
value={this.state.twoFactorAuthCode}
onChangeText={(text) => this.onTextInput(text, 'twoFactorAuthCode')}
onFulfill={this.validateAndSubmitForm}
maxLength={CONST.TFA_CODE_LENGTH}
errorText={this.state.formError.twoFactorAuthCode ? this.props.translate(this.state.formError.twoFactorAuthCode) : ''}
hasError={hasError}
autoFocus
/>
</View>
) : (
<View style={[styles.mv3]}>
<MagicCodeInput
autoComplete={this.props.autoComplete}
ref={(el) => (this.inputValidateCode = el)}
label={this.props.translate('common.magicCode')}
name="validateCode"
value={this.state.validateCode}
onChangeText={(text) => this.onTextInput(text, 'validateCode')}
onFulfill={this.validateAndSubmitForm}
errorText={this.state.formError.validateCode ? this.props.translate(this.state.formError.validateCode) : ''}
hasError={hasError}
autoFocus
/>
<View style={[styles.changeExpensifyLoginLinkContainer]}>
{this.state.linkSent ? (
<Text style={[styles.mt2]}>{this.props.account.message ? this.props.translate(this.props.account.message) : ''}</Text>
) : (
<TouchableOpacity
style={[styles.mt2]}
onPress={this.resendValidateCode}
underlayColor={themeColors.componentBG}
>
<Text style={[styles.link]}>{this.props.translate('validateCodeForm.magicCodeNotReceived')}</Text>
</TouchableOpacity>
)}
</View>
</View>
)}

We can see there is autofocus set at line 211 and 226 although it only focus during magic code input but not during 2FA inout.

So here problem that we are rendering same component conditionally within same parent, so here react will just pass the new props and keep the component loaded. So component did mount will not trigger when 2FA input appear. This is the root cause of the problem.

What changes do you think we should make in order to solve the problem?

We have to pass unique key prop to <MagicCodeInput> component render at line 200 and 216 as shown code below.

{this.props.account.requiresTwoFactorAuth ? ( 
     <View style={[styles.mv3]}> 
         <MagicCodeInput 
             ...
            key="2FAInput"  // *** Add this prop ***
         /> 
     </View> 
 ) : ( 
     <View style={[styles.mv3]}> 
         <MagicCodeInput 
             ...
            key="magicCodeInput"   // *** Add this prop ***
         /> 
         <View style={[styles.changeExpensifyLoginLinkContainer]}> 
            ...
         </View> 
     </View> 
 )} 

So react will treat both component different and it will mount component from scratch instead of just passing the new props. This will solve the issue as shown in result video.

Note: At present I set key for both component for sample purpose, we can decide key as suggested by engineering team.

What alternative solutions did you explore? (Optional)

None

Result
19711-2FA-AutoFocus.mp4

@melvin-bot melvin-bot bot added the Overdue label May 29, 2023
@kadiealexander
Copy link
Contributor

Reproduced on staging web!

2023-05-30_14-01-08.mp4

@melvin-bot melvin-bot bot removed the Overdue label May 30, 2023
@kadiealexander kadiealexander added the External Added to denote the issue can be worked on by a contributor label May 30, 2023
@melvin-bot melvin-bot bot changed the title Web - Login - 2FA Input field not focused when proceed from magic code page [$1000] Web - Login - 2FA Input field not focused when proceed from magic code page May 30, 2023
@melvin-bot
Copy link

melvin-bot bot commented May 30, 2023

Job added to Upwork: https://www.upwork.com/jobs/~0145b8fd18db4b7dff

@melvin-bot
Copy link

melvin-bot bot commented May 30, 2023

Current assignee @kadiealexander is eligible for the External assigner, not assigning anyone new.

@melvin-bot
Copy link

melvin-bot bot commented May 30, 2023

Triggered auto assignment to Contributor-plus team member for initial proposal review - @abdulrahuman5196 (External)

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label May 30, 2023
@melvin-bot
Copy link

melvin-bot bot commented May 30, 2023

Triggered auto assignment to @marcaaron (External), see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@ShogunFire
Copy link
Contributor

Does @PrashantMangukiya 's proposal counts or are you waiting for proposals ? His proposal looks good... Can I copy paste it and get chosen ahah ?

@kadiealexander
Copy link
Contributor

Prashant's proposal counts, we're just waiting on @abdulrahuman5196 to review it. If you have your own proposal to share, by all means go ahead! :)

@abdulrahuman5196
Copy link
Contributor

Reviewing now

@abdulrahuman5196
Copy link
Contributor

@PrashantMangukiya The proposal is not working iOS safari? Could you kindly check on that?
But it works on web desktop, ios native

So here problem that we are rendering same component conditionally within same parent, so here react will just pass the new props and keep the component loaded. So component did mount will not trigger when 2FA input appear.

I am not entirely sure on the rootcause. Why do we think this happens? Similarity in end DOM structure? Could you add more information to this and any react native reference possible.

@marcaaron
Copy link
Contributor

FWIW, auto focusing inputs is really messed up on iOS Safari and doesn't work properly for many cases see this really long issue thread 😄

#10414

@PrashantMangukiya
Copy link
Contributor

PrashantMangukiya commented Jun 4, 2023

@PrashantMangukiya The proposal is not working iOS safari? Could you kindly check on that?
But it works on web desktop, ios native

Yes autofocus for safari is messes up as mentioned in comment above. #19711 (comment)

So here problem that we are rendering same component conditionally within same parent, so here react will just pass the new props and keep the component loaded. So component did mount will not trigger when 2FA input appear.

I am not entirely sure on the rootcause. Why do we think this happens? Similarity in end DOM structure? Could you add more information to this and any react native reference possible.

@abdulrahuman5196 here is the react doc link related to this. Here they mention to reset state with key. Thank you.

@abdulrahuman5196
Copy link
Contributor

@PrashantMangukiya Thanks for references.

Tested in all platforms.

The solutions works for most platforms except iOS safari and native android.
It seems iOS safari is auto focus is messed up. So it should be fine for now.

But could you check why its not working on native android?(Not sure if its existing issue as well.)

@abdulrahuman5196
Copy link
Contributor

@PrashantMangukiya Where you able to get any information for the fix to work in android native as well?

@PrashantMangukiya
Copy link
Contributor

@abdulrahuman5196 I tried but was not able to find any fix for android native yet.

@melvin-bot
Copy link

melvin-bot bot commented Jun 6, 2023

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@kadiealexander kadiealexander changed the title [$1000] Web - Login - 2FA Input field not focused when proceed from magic code page [$2000] Web - Login - 2FA Input field not focused when proceed from magic code page Jun 7, 2023
@WikusKriek
Copy link
Contributor

@abdulrahuman5196 The proposal looks good to me 👍 The only suggestion I make is that instead of using the clear method, which might be confusing (the concern raised by @hoangzinh), is to create another one called resetFocus or something, that includes the setInput(''). This is only a suggestion, feel free to discard it if you don't agree.

I think either way will work, it just feels like clear already fits perfectly for what we want to do here. It makes sense on both the cases to call clear when the component is initiated. Like @abdulrahuman5196 mentioned it is better to clear all the stale data. But yeah if we want to rather create a new resetFocus alongside the clear and focus it will also work.

@abdulrahuman5196
Copy link
Contributor

abdulrahuman5196 commented Jun 15, 2023

I agree on the concerns and suggestions by @BeeMargarida and @hoangzinh here. I think the suggestion of a new method called resetFocus or similar from @BeeMargarida make sense and we should also need to make sure this new method is dry compared to focus and clear. But anyways these are PR level suggestion and the contributor would have to address these concerns during the PR phase.
cc: @WikusKriek

@luacmartins
Copy link
Contributor

Proposal looks good. Let's please also address this comment in the solution

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jun 15, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jun 15, 2023

📣 @WikusKriek You have been assigned to this job by @luacmartins!
Please apply to this job in Upwork and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@WikusKriek
Copy link
Contributor

Proposal looks good. Let's please also address this comment in the solution

Thanks, I will address the comments and open the PR shortly.

@WikusKriek
Copy link
Contributor

@abdulrahuman5196 please note that there was a functional component refactor for BaseValidateCodeForm. The issue does still exist and I made the changes as requested and the fix is still valid.

@kadiealexander
Copy link
Contributor

Hey team! I'm just adding a note that I'll be OOO until June 26th. I don't think any bug0 team actions will come up this week but if you need a bug0 teammate while I'm gone, please reapply the label! Thanks.

@melvin-bot
Copy link

melvin-bot bot commented Jun 20, 2023

Based on my calculations, the pull request did not get merged within 3 working days of assignment. Please, check out my computations here:

  • when @WikusKriek got assigned: 2023-06-15 21:14:14 Z
  • when the PR got merged: 2023-06-20 15:25:31 UTC
  • days elapsed: 3

On to the next one 🚀

@abdulrahuman5196
Copy link
Contributor

Melvin is wrong here. PR was merged within 3 working days totally, almost 6 hours before 3 days mark (2 days being weekend out of the 5 days).

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Daily KSv2 labels Jun 22, 2023
@melvin-bot melvin-bot bot changed the title [$2000] Web - Login - 2FA Input field not focused when proceed from magic code page [HOLD for payment 2023-06-29] [$2000] Web - Login - 2FA Input field not focused when proceed from magic code page Jun 22, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jun 22, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jun 22, 2023

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot
Copy link

melvin-bot bot commented Jun 22, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.30-5 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-06-29. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@melvin-bot
Copy link

melvin-bot bot commented Jun 22, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@abdulrahuman5196] The PR that introduced the bug has been identified. Link to the PR: n/a
  • [@abdulrahuman5196] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment: n/a
  • [@abdulrahuman5196] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion: n/a
  • [@abdulrahuman5196] Determine if we should create a regression test for this bug.
  • [@abdulrahuman5196] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@kadiealexander] Link the GH issue for creating/updating the regression test once above steps have been agreed upon: https://github.com/Expensify/Expensify/issues/295808

@abdulrahuman5196
Copy link
Contributor

The PR that introduced the bug has been identified. Link to the PR:
The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:

Doesn't seem to be a regression. But was present from original implementation.

Determine if we should create a regression test for this bug.

yes

If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.

  1. Go to login page and enter login information where the account already has Two factor authentication enabled
  2. Enter magic code and continue
  3. Two factor code input should be focused and keyboards should be opened in-case on native apps

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jun 28, 2023
@abdulrahuman5196
Copy link
Contributor

@kadiealexander Thank you. Accepted the upwork job offer.

@WikusKriek
Copy link
Contributor

@kadiealexander I also accepted, thanks!

@kadiealexander
Copy link
Contributor

Everyone is paid (plus a bonus as per #19711 (comment)). Thanks for the speedy work team!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

10 participants