Skip to content

[HOLD for payment 2023-08-08] [$1000] Web - App crashes after pressing Backspace/Delete key in Incorrect magic code page #23596

Closed

Description

@kbecciv

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:

  1. On login page, enter an email/phone number and click Continue
  2. Enter WRONG Magic code
  3. When the error is showing, hold the left-mouse button and drag over the Magic code field - (like we are selecting text BUT do not show the selection)
  4. Press Backspace/Delete key on the keyboard

Expected Result:

Application should not crash

Actual Result:

Application crashes

Workaround:

Unknown

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.45-1
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

CRASH.mp4
Recording.3910.mp4

Expensify/Expensify Issue URL:
Issue reported by: @tranvantoan-qn
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1690254789469459

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~017414e8528c6cdd44
  • Upwork Job ID: 1684228115617501184
  • 2023-07-26
  • Automatic offers:
    • s77rt | Reviewer | 25775610
    • Pujan92 | Contributor | 25775614
    • tranvantoan-qn | Reporter | 25775617

Activity

  1. added
    Daily
    Bug
    on Jul 25, 2023
  2. melvin-bot commented on Jul 25, 2023

    @melvin-bot

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

  3. melvin-bot commented on Jul 25, 2023

    @melvin-bot

    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
  4. kbecciv commented on Jul 25, 2023

    @kbecciv
    Author

    Proposal: @tranvantoan-qn
    Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1690254789469459

    Proposal

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

    App crashes after pressing Backspace/Delete key in Incorrect magic code page

    What is the root cause of that problem?

    After dragging, the editIndex will be undefined, making it unable to retrieve the object. Unfortunately, in the following code, we did not check for this scenario, which results in an app crash:
    https://github.com/Expensify/App/blob/main/src/components/MagicCodeInput.js#L105

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

    To prevent the crash, add the following condition:

            if (inputRefs.current[editIndex]) { 
                inputRefs.current[editIndex].blur();    
            }
  5. huzaifa-99 commented on Jul 26, 2023

    @huzaifa-99
    Contributor

    Proposal

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

    We want the app to not crash when backspace key is pressed on the magic code input (after drag select)

    What is the root cause of that problem?

    When we submit the form (it happens when we fill the last cell of input), then we set the focused index to undefined here.

    And next, when we drag over the whole input, the focus event gets triggered, but we don't update the focused and edit index in that event. And next, when we press backspace, the focused index will still be undefined which causes the editIndex to also become undefined, and on blur, this undefined editIndex crashes the app.

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

    I think we should use a single type for focusedIndex, and not use undefined (we can add -1 in place of that). This is important because eventually, we will be moving to typescript.

    So when we blur the input we should set the focused index to -1 here.

    And on focus event, when focusedIndex is -1, we update the focused index to the current cell index like this

    if (focusedIndex == -1) {
        setInput('');
        setEditIndex(index)
        setFocusedIndex(index)
    }
    

    and we update the focus event of text input like this

    onFocus={(event) => onFocus(event, index)}
    

    Now when backspace is pressed, the focusedIndex will be properly defined.

    I used -1 to indicate that no cell is focused, we can use any other number value here

    Focus event triggers before the press event. We can optimize the state updates in this case

    What alternative solutions did you explore? (Optional)

    Block the drag selection on the magic code input

  6. added
    External
    on Jul 26, 2023
  7. changed the title [-]Web - App crashes after pressing Backspace/Delete key in Incorrect magic code page[/-] [+][$1000] Web - App crashes after pressing Backspace/Delete key in Incorrect magic code page[/+] on Jul 26, 2023
  8. melvin-bot commented on Jul 26, 2023

    @melvin-bot
  9. added
    Help Wanted
    on Jul 26, 2023
  10. melvin-bot commented on Jul 26, 2023

    @melvin-bot

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

  11. melvin-bot commented on Jul 26, 2023

    @melvin-bot

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

  12. CortneyOfstad commented on Jul 26, 2023

    @CortneyOfstad
    Contributor

    @s77rt we have a couple of proposals for your review above 👍 TIA!

  13. 44 remaining items

  14. added
    Weekly
    Awaiting Payment
    on Aug 1, 2023
  15. changed the title [-][$1000] Web - App crashes after pressing Backspace/Delete key in Incorrect magic code page[/-] [+][HOLD for payment 2023-08-08] [$1000] Web - App crashes after pressing Backspace/Delete key in Incorrect magic code page[/+] on Aug 1, 2023
  16. removed
    Reviewing
    on Aug 1, 2023
  17. melvin-bot commented on Aug 1, 2023

    @melvin-bot

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

  18. melvin-bot commented on Aug 1, 2023

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.48-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-08-08. 🎊

    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

    For reference, here are some details about the assignees on this issue:

    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
  19. melvin-bot commented on Aug 1, 2023

    @melvin-bot

    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:

    • [@s77rt] The PR that introduced the bug has been identified. Link to the PR:
    • [@s77rt] 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:
    • [@s77rt] 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:
    • [@s77rt] Determine if we should create a regression test for this bug.
    • [@s77rt] 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.
    • [@JmillsExpensify / @CortneyOfstad] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
  20. s77rt commented on Aug 3, 2023

    @s77rt
    Member
  21. added
    Daily
    and removed
    Weekly
    on Aug 8, 2023
  22. CortneyOfstad commented on Aug 14, 2023

    @CortneyOfstad
    Contributor

    I am back from OoO, so taking this back over. Thanks @s77rt for the review above!

  23. CortneyOfstad commented on Aug 14, 2023

    @CortneyOfstad
    Contributor

    Payments have been made!

    @tranvantoan-qn was paid the reporting amount of $250
    @Pujan92 and @s77rt were both paid $1,500 (contributor and C+ fee, plus bonus due to the PR being merged within 1 day of assignment).

    Closing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternal

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions