Skip to content

[HOLD for payment 2023-08-28] [$1000] There is Console log error when pressing ESC key while Composer is focused #24232

Closed

Description

@kavimuru

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: Open Console log tool to capture console log
CASE 1:

  1. Login to any account.
  2. Press ESC key right after logged-in
  3. Observe: A console log error occurs.
    CASE 2:
  4. Click to open any chat report
  5. Click on the Composer to focus on it (if not focused yet).
  6. Press the ESC key.
  7. Observe: A console log error occurs.

Expected Result:

There should be no console log error.

Actual Result:

A console log error appears every time the ESC key is pressed.

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.50.3
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

Console-Log-Error-ESC.mp4
Recording.5767.mp4

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

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01751354c92045a580
  • Upwork Job ID: 1688663520088018944
  • Last Price Increase: 2023-08-14
  • Automatic offers:
    • tienifr | Contributor | 26135709

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Aug 7, 2023
  2. melvin-bot commented on Aug 7, 2023

    @melvin-bot

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

  3. melvin-bot commented on Aug 7, 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. jeet-dhandha commented on Aug 7, 2023

    @jeet-dhandha
    Contributor

    Proposal

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

    • Error is logged when pressing escape just after logging in.

    What is the root cause of that problem?

    • The modal is setting null for first time when subscribing to onyx store after logging in.

    let modal = {};
    this.unsubscribeOnyxModal = onyxSubscribe({
    key: ONYXKEYS.MODAL,
    callback: (modalArg) => {
    modal = modalArg;
    },
    });

    • Thus its throwing error when pressing escape just after logging in.

    this.unsubscribeEscapeKey = KeyboardShortcut.subscribe(
    shortcutConfig.shortcutKey,
    () => {
    if (modal.willAlertModalBecomeVisible) {
    return;
    }
    Navigation.dismissModal();
    },

    Video For Logs
    3bdd25bc-cc6b-4f40-8bfd-0a2f9a771b5a.mp4

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

    • We can add a check for modal before setting it to null.
    this.unsubscribeOnyxModal = onyxSubscribe({
        key: ONYXKEYS.MODAL,
        callback: (modalArg) => {
    +       if (!modalArg) {
    +           return;
    +       }
            modal = modalArg;
        },
    });
    • Thus not setting it null.

    What alternative solutions did you explore? (Optional)

    • We can try to find cause why is it setting null for first time.
  5. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Aug 7, 2023
  6. changed the title [-]There is Console log error when pressing ESC key while Composer is focused[/-] [+][$1000] There is Console log error when pressing ESC key while Composer is focused[/+] on Aug 7, 2023
  7. melvin-bot commented on Aug 7, 2023

    @melvin-bot
  8. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Aug 7, 2023
  9. melvin-bot commented on Aug 7, 2023

    @melvin-bot

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

  10. melvin-bot commented on Aug 7, 2023

    @melvin-bot

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

  11. tienifr commented on Aug 8, 2023

    @tienifr
    Contributor

    Proposal

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

    A console log error appears every time the ESC key is pressed.

    What is the root cause of that problem?

    We're not initializing the default value of the ONYXKEYS.MODAL on app start up so it's null for the first time. This causes the error here when we access it properties. It will have value when the Modal or PopoverWithoutOverlay are mounted, which set its value (as in here).

    So it's a race condition and hard to reproduce, we should press ESC very quickly after signing in. For easier reproduction, can comment out this line and this line so the race condition is more visible.

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

    We should initialize the ONYXKEYS.MODAL on app start up here

    [ONYXKEYS.MODAL]: {
        isVisible: false,
        willAlertModalBecomeVisible: false,
    }
    

    This will make sure any future places that will be using onyxSubscribe with ONYXKEYS.MODAL is protected. Also the isVisible and willAlertModalBecomeVisible is now of correct boolean type around the app (no case of undefined)

    What alternative solutions did you explore? (Optional)

    We can modify this line

    to

    modal = modalArg || {};
    

    Cannot just early return since if somehow the value is cleared in the future, the modal value here will not be reset.

    Or, since only willAlertModalBecomeVisible is used and no need to store the full modal object, we can use a simple willAlertModalBecomeVisible variable and replace the above line with

    willAlertModalBecomeVisible = lodashGet(modalArg, 'willAlertModalBecomeVisible', false);
    
  12. jeet-dhandha commented on Aug 9, 2023

    @jeet-dhandha
    Contributor

    Proposal [UPDATED] => (#24232 (comment))

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

    • Error is logged when pressing escape just after logging in.

    What is the root cause of that problem?

    • The modal is setting null for first time when subscribing to onyx store after logging in.

    let modal = {};
    this.unsubscribeOnyxModal = onyxSubscribe({
    key: ONYXKEYS.MODAL,
    callback: (modalArg) => {
    modal = modalArg;
    },
    });

    • Thus it is throwing an error when pressing escape just after logging in. (We need to press 'esc' rapidly after logging in to reproduce the issue. Also this happens only when we logout and login again.)

    this.unsubscribeEscapeKey = KeyboardShortcut.subscribe(
    shortcutConfig.shortcutKey,
    () => {
    if (modal.willAlertModalBecomeVisible) {
    return;
    }
    Navigation.dismissModal();
    },

    Video For Logs
    3bdd25bc-cc6b-4f40-8bfd-0a2f9a771b5a.mp4

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

    • We can add a check for modal before setting it to null.
    this.unsubscribeOnyxModal = onyxSubscribe({
        key: ONYXKEYS.MODAL,
        callback: (modalArg) => {
    
    +       // Using return as we have been using this code typo for other callbacks like in Report.js, ReportActionsUtils.js, etc.
    +       if (!modalArg) {
    +           return;
    +       }
    
            modal = modalArg;
        },
    });
    • Hence not setting it null.

    What alternative solutions did you explore? (Optional)

    • We can add default modal data in CONST.js and use it as a default value for modal in setup.js.
    • CONST.js
    DEFAULT_MODAL_DATA: {isVisible: false, willAlertModalBecomeVisible: false}
    
    • setup.js
    [ONYXKEYS.MODAL]: CONST.DEFAULT_MODAL_DATA,
    
  13. 30 remaining items

  14. puneetlath commented on Aug 28, 2023

    @puneetlath
    Contributor

    @eVoloshchak bump on the checklist!

  15. eVoloshchak commented on Aug 28, 2023

    @eVoloshchak
    Contributor
    • The PR that introduced the bug has been identified. Link to the PR: there isn't a PR that introduced this bug, that's how it was implemented initially
    • 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
    • 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: This is an extremely rare edge case, it's hard to reproduce since it's caused by a race condition and can be reproduced only after login. I don't think there are additional steps we should add, this is a pretty rare type of bug
    • Determine if we should create a regression test for this bug.
      I don't think a regression test is necessary. As stated above, this is a rare edge case, in addition to having zero impact on actual user experience
  16. puneetlath commented on Aug 29, 2023

    @puneetlath
    Contributor
  17. puneetlath commented on Aug 29, 2023

    @puneetlath
    Contributor

    Payment summary:

    • External issue reporter @tranvantoan-qn (paid via Upwork) $250
    • Contributor that fixed the issue @tienifr (paid via Upwork) $1500
    • Contributor+ that helped on the issue and/or PR @eVoloshchak (to be paid via NewDot) $1500

    @eVoloshchak can you create a manual request in NewDot and then ping me here when you have?

  18. eVoloshchak commented on Aug 29, 2023

    @eVoloshchak
    Contributor

    @puneetlath, created the payment request

  19. tranvantoan-qn commented on Aug 29, 2023

    @tranvantoan-qn

    @puneetlath
    I've applied for the job, thank you!

  20. JmillsExpensify commented on Aug 30, 2023

    @JmillsExpensify
    Contributor

    @puneetlath do you mind adding the amount in the summary above. I see the automated confirmation and I reviewed the PR, though let's make sure we have those for the history.

  21. JmillsExpensify commented on Aug 30, 2023

    @JmillsExpensify
    Contributor

    Reviewed the details for @eVoloshchak. $1,500 approved for payment via NewDot.

  22. puneetlath commented on Aug 31, 2023

    @puneetlath
    Contributor

    My apologies! Added.

    Thanks everyone!

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions