Skip to content

[HOLD for payment 2023-10-23] [HOLD for payment 2023-10-23] [HOLD for payment 2023-10-20] [HOLD for payment 2023-10-20] [$1000] IOU - Selecting currency in BNP and pressing "CMD+ENTER" results in accidental redirection #23395

Closed

Description

@lanitochka17

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. Open https://staging.new.expensify.com/
  2. Select any valid 1:1 chat room
  3. Click on the + button in the compose box.
  4. Click on "Request money" in the action menu
  5. Enter any amount of currency
  6. Click on the currency
  7. In the currency selection menu, press the "CMD+ENTER" key combination

Expected Result:

The modal window of currency selection should close and the user should get to the previous window of currency amount input with correctly selected currency

Actual Result:

The modal currency selection window closes and the user is redirected to a random chat

Workaround:

Unknown

Platforms:

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

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

Version Number: 1.3.44.0

Reproducible in staging?: Yes

Reproducible in production?: Yes

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

Bug6137428_Recording__104.mp4

Expensify/Expensify Issue URL:

Issue reported by: Applause - Inernal Team

Slack conversation:

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~015204edc11a150c2b
  • Upwork Job ID: 1684299342131027968
  • Last Price Increase: 2023-08-02
  • Automatic offers:
    • mollfpr | Reviewer | 25995133
    • samh-nl | Contributor | 25995135

Activity

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

    @melvin-bot

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

  3. melvin-bot commented on Jul 22, 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. rayane-d commented on Jul 22, 2023

    @rayane-d
    Contributor

    Proposal

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

    The existing issue lies in the currency selection functionality of the app. After selecting currency for a money request in a chat room, a combination of "CMD+ENTER" keys results in an unwanted redirection to a random chat room, instead of just closing the currency selection menu and returning to the previous window.

    What is the root cause of that problem?

    The cause of the problem appears to be tied to the handling of the "CMD+ENTER" key combination in the app. Currently, the event listener in the currency selection menu is not configured to properly handle this key combination, leading to the accidental redirection.

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

    To address this issue, we need to modify the code in the CurrencySymbolButton.js file.

    function CurrencySymbolButton(props) {
    return (
    <Tooltip text={props.translate('iOUCurrencySelection.selectCurrency')}>
    <PressableWithoutFeedback
    onPress={props.onCurrencyButtonPress}
    accessibilityLabel={props.translate('iOUCurrencySelection.selectCurrency')}
    accessibilityRole={CONST.ACCESSIBILITY_ROLE.BUTTON}
    >
    <Text style={styles.iouAmountText}>{props.currencySymbol}</Text>
    </PressableWithoutFeedback>
    </Tooltip>
    );
    }

    Here's the proposed code modification to handle the "CMD+ENTER" key combination, prevent the default behavior (which is triggering the form submission) and close the currency selection modal:

    function CurrencySymbolButton(props) {
        const handleKeyDown = (event) => {
            if (event.metaKey && event.key === 'Enter') {
                event.preventDefault();
                props.onCurrencyButtonPress();
            }
        };
    
        return (
            <Tooltip text={props.translate('iOUCurrencySelection.selectCurrency')}>
                <PressableWithoutFeedback
                    onPress={props.onCurrencyButtonPress}
                    accessibilityLabel={props.translate('iOUCurrencySelection.selectCurrency')}
                    accessibilityRole={CONST.ACCESSIBILITY_ROLE.BUTTON}
                    onKeyDown={handleKeyDown} // Added the keydown event listener here
                >
            ...

    What alternative solutions did you explore? (Optional)

    None.

  5. samh-nl commented on Jul 22, 2023

    @samh-nl
    Contributor

    Proposal

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

    Pressing CMD+Enter while selecting the currency closes the modal.

    What is the root cause of that problem?

    In the BaseOptionsSelector component, CMD+Enter is subscribed to for selecting rows:

    const CTRLEnterConfig = CONST.KEYBOARD_SHORTCUTS.CTRL_ENTER;
    this.unsubscribeCTRLEnter = KeyboardShortcut.subscribe(
    CTRLEnterConfig.shortcutKey,

    The callback is executed twice due to a bug in react-native-key-command, where both Enter and CMD+Enter are processed for the CMD+Enter shortcut and executed. This is due to a missing check for the correct modifierFlags, which should also match in the case of no modifier flags present (i.e. just Enter) in the input, but expected in the listener.

    https://github.com/Expensify/react-native-key-command/blob/5b093ed48c9bb90f047c7a3f1267e384298c1018/src/index.js#L96-L102

    Subsequently, confirmCurrencySelection is called twice in IOUCurrencySelection leading to a double navigation, therefore closing the modal.

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

    We should ensure that the input modifiers are correctly checked in react-native-key-command (this line):

    - if (!validatedKeyCommand.modifierFlags && isInputMatched) {
    + if (!validatedKeyCommand.modifierFlags && isInputMatched && isCommandMatched) {

    Instead of the two if-statements contained in this function, we can also simplify this by combining them to: if (isInputMatched && isCommandMatched) {

    What alternative solutions did you explore? (Optional)

    Alternatively, we can add a debounce time to prevent the callback from being executed twice.

  6. MitchExpensify commented on Jul 24, 2023

    @MitchExpensify
    Contributor

    @mountiny buddy check on this keyboard command actually being a platform wide expectation the same as hitting "Enter" on its own

  7. mountiny commented on Jul 25, 2023

    @mountiny
    Contributor

    @MitchExpensify I am not sure about this one, seems like a niche edge case where I am not sure if we should worry about.

  8. mountiny commented on Jul 25, 2023

    @mountiny
    Contributor

    @azimgd from your experience, have we been catching such flows before?

  9. samh-nl commented on Jul 25, 2023

    @samh-nl
    Contributor

    @MitchExpensify Only pressing Enter does not trigger the event listening to CMD+Enter. It's when the combination is pressed that both are processed, leading to a double execution of the callback.

    It's a general problem when listening to a combination of keys where modifiers are involved.

  10. mountiny commented on Jul 25, 2023

    @mountiny
    Contributor

    Yeah so I think if we want to solve this it would have to be in general

  11. samh-nl commented on Jul 25, 2023

    @samh-nl
    Contributor

    I traced it back to the react-native-key-command library, feel free to read the details in my proposal above.

  12. MitchExpensify commented on Jul 26, 2023

    @MitchExpensify
    Contributor

    Ok cool, as long as we solve in general this seems worth fixing

  13. 104 remaining items

  14. melvin-bot commented on Oct 16, 2023

    @melvin-bot

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

    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
  15. melvin-bot commented on Oct 16, 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:

    • [@johnmlee101] The PR that introduced the bug has been identified. Link to the PR:
    • [@johnmlee101] 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:
    • [@johnmlee101] 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:
    • [@mollfpr / @samh-nl] Determine if we should create a regression test for this bug.
    • [@mollfpr / @samh-nl] 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.
    • [@MitchExpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
  16. MitchExpensify commented on Oct 18, 2023

    @MitchExpensify
    Contributor

    Wow whats up Melvin! Is this actually being held for payment at this point?

  17. mollfpr commented on Oct 20, 2023

    @mollfpr
    Contributor

    [@johnmlee101] The PR that introduced the bug has been identified. Link to the PR:
    [@johnmlee101] 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:

    Expensify/react-native-key-command#5

    There's also another PR in the E/App that causing the issue, because it got resolve before the fix in upstream merged.

    [@johnmlee101] 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:

    The regression step should be enough.

    [@mollfpr / @samh-nl] Determine if we should create a regression test for this bug.
    [@mollfpr / @samh-nl] 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. Click on the FAB
    2. Go to Request money
    3. Click on the currency symbol to open the currency selector
    4. Press CMD+Enter
    5. Verify that the currency selector is closed, returning the user to the enter money amount page
    6. 👍 or 👎
  18. MitchExpensify commented on Oct 22, 2023

    @MitchExpensify
    Contributor

    Mind helping me understand if the fix has been on prod for 7 days without regression @mollfpr? The Melvin updates are causing me doubt

  19. mollfpr commented on Oct 23, 2023

    @mollfpr
    Contributor

    @MitchExpensify The PR is included in the production release: https://github.com/Expensify/App/releases/tag/1.3.83-11, which is on Oct 14th.

  20. MitchExpensify commented on Oct 25, 2023

    @MitchExpensify
    Contributor

    Payment summary:

    • $500 (50% 8+ day penalty) @mollfpr requires payment offer (Reviewer)
    • $500 (50% 8+ day penalty) @samh-nl requires payment offer (Contributor)
  21. MitchExpensify commented on Oct 25, 2023

    @MitchExpensify
    Contributor

    Mind taking a peak at the BZ steps @johnmlee101 #23395 (comment) 👀

  22. mollfpr commented on Oct 25, 2023

    @mollfpr
    Contributor

    @MitchExpensify I already have the Upwork contract.

  23. MitchExpensify commented on Oct 28, 2023

    @MitchExpensify
    Contributor

    Paid and contracts ended!

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