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 2024-02-07] [HOLD for payment 2024-02-05] IOU - CMD+Enter command does not work when selecting currency #35235

Closed
2 of 6 tasks
kbecciv opened this issue Jan 26, 2024 · 18 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Daily KSv2 Engineering

Comments

@kbecciv
Copy link

kbecciv commented Jan 26, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 1.4.32-2
Reproducible in staging?: y
Reproducible in production?: n
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
Expensify/Expensify Issue URL:
Issue reported by: Applause - Internal Team
Slack conversation:

Action Performed:

  1. Open https://staging.new.expensify.com/
  2. Log in under your HT account
  3. Tap on the green plus button (FAB)
  4. Select Request money
  5. In RHP, click on currency
  6. Press CMD+Enter

Expected Result:

The CMD+Enter command should close the currency toggle, returning the user to the money amount entry page

Actual Result:

CMD+Enter command does not work when selecting currency

Workaround:

Unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6355597_1706262292979.Recording__1201.mp4

View all open jobs on GitHub

@kbecciv kbecciv added the DeployBlockerCash This issue or pull request should block deployment label Jan 26, 2024
Copy link
Contributor

👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

Copy link

melvin-bot bot commented Jan 26, 2024

Triggered auto assignment to @cristipaval (Engineering), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

@kbecciv
Copy link
Author

kbecciv commented Jan 26, 2024

We think that this bug might be related to #vip-bills
CC @davidcardoza

@dukenv0307
Copy link
Contributor

dukenv0307 commented Jan 26, 2024

Proposal

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

  • IOU - CMD+Enter command does not work when selecting currency

What is the root cause of that problem?

  • In here, onConfirm is ()=>{} so CMD+ENTER does not do anything

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

                <SelectionList
                    onConfirm={(option) => {
                        confirmCurrencySelection(option);
                    }}
                    ...
  • Then in BaseSelectionList, we update the onConfim function so it can receive option param and works properly

What alternative solutions did you explore? (Optional)

  • In here, in this case (selecting currency), we should use selectFocusedOption rather than onConfirm.

  • To keep the backward compatibility, we can add the condition to know when we should use onConfirm, and when we should use selectFocusedOption. For example, create param shouldConsiderEnterSamAsCmdEnter. if true, use selectFocusedOption

@paultsimura
Copy link
Contributor

The offending PR is this migration: #34794

cc: @allroundexperts

@allroundexperts
Copy link
Contributor

@paultsimura Thanks for pointing out. Do you mind giving a short explanation of why this is the case?

@paultsimura
Copy link
Contributor

paultsimura commented Jan 26, 2024

@paultsimura Thanks for pointing out. Do you mind giving a short explanation of why this is the case?

I'll try 🙂

Here, we're now setting the default value for onConfirm (previously it was undefined, and I think it should remain such):

Then, here we use the !!onConfirm check, which is now true (unless undefined was passed explicitly):

/** Calls confirm action when pressing CTRL (CMD) + Enter */
useKeyboardShortcut(CONST.KEYBOARD_SHORTCUTS.CTRL_ENTER, onConfirm, {
captureOnInputs: true,
shouldBubble: !flattenedSections.allOptions[focusedIndex],
isActive: !disableKeyboardShortcuts && !!onConfirm && isFocused,
});

But since onConfirm is an empty function, this command does nothing.
And this shorcut overlaps with this line:

onSubmitEditing={selectFocusedOption}

Now pressing CMD+Enter does not trigger onSubmitEditing (which is the part that actually works in Prod currently – if you unfocus the input and use CMD+Enter in prod, it does nothing either) because the keyboard listener with empty function is a higher level one, and it gets executed instead.

@allroundexperts
Copy link
Contributor

@filip-solecki This should be a quick fix. Can you raise a PR?

@paultsimura
Copy link
Contributor

Proposal

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

The CMD+Enter does nothing on selection lists with no onConfirm passed

What is the root cause of that problem?

The offending PR is this migration: #34794

We're now setting the default value for onConfirm (previously it was undefined):

Then, here we use the !!onConfirm check, which is now true (unless undefined was passed explicitly):

/** Calls confirm action when pressing CTRL (CMD) + Enter */
useKeyboardShortcut(CONST.KEYBOARD_SHORTCUTS.CTRL_ENTER, onConfirm, {
captureOnInputs: true,
shouldBubble: !flattenedSections.allOptions[focusedIndex],
isActive: !disableKeyboardShortcuts && !!onConfirm && isFocused,
});

But since onConfirm is an empty function, this command does nothing.

And this shortcut overlaps with this line:

onSubmitEditing={selectFocusedOption}

Now pressing CMD+Enter does not trigger onSubmitEditing (which is the part that actually works in Prod currently – if you unfocus the input and use CMD+Enter in prod, it does nothing either) because the keyboard listener with an empty function is a higher level one, and it gets executed instead.

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

Instead of setting the default value to onConfirm, we should leave it undefined by default, and instead change this code to add the listener only if onConfirm is not falsy:

    if (!!onConfirm) {
        /** Calls confirm action when pressing CTRL (CMD) + Enter */
        useKeyboardShortcut(CONST.KEYBOARD_SHORTCUTS.CTRL_ENTER, onConfirm, {
            captureOnInputs: true,
            shouldBubble: !flattenedSections.allOptions[focusedIndex],
            isActive: !disableKeyboardShortcuts && isFocused,
        });
    }

/** Calls confirm action when pressing CTRL (CMD) + Enter */
useKeyboardShortcut(CONST.KEYBOARD_SHORTCUTS.CTRL_ENTER, onConfirm, {
captureOnInputs: true,
shouldBubble: !flattenedSections.allOptions[focusedIndex],
isActive: !disableKeyboardShortcuts && !!onConfirm && isFocused,
});

What alternative solutions did you explore? (Optional)

@allroundexperts
Copy link
Contributor

    if (!!onConfirm) {
        /** Calls confirm action when pressing CTRL (CMD) + Enter */
        useKeyboardShortcut(CONST.KEYBOARD_SHORTCUTS.CTRL_ENTER, onConfirm, {
            captureOnInputs: true,
            shouldBubble: !flattenedSections.allOptions[focusedIndex],
            isActive: !disableKeyboardShortcuts && isFocused,
        });
    }

This violates the rule of the hooks.

@filip-solecki
Copy link
Contributor

@allroundexperts - sure, I am preparing PR

@filip-solecki
Copy link
Contributor

@allroundexperts - PR created, right now onConfirm function may be undefined and if it is code runs selectFocusedOption function which select focused element

@allroundexperts
Copy link
Contributor

Reviewing in a moment.

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Hourly KSv2 Weekly KSv2 labels Jan 26, 2024
@melvin-bot melvin-bot bot changed the title IOU - CMD+Enter command does not work when selecting currency [HOLD for payment 2024-02-05] IOU - CMD+Enter command does not work when selecting currency Jan 29, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jan 29, 2024
Copy link

melvin-bot bot commented Jan 29, 2024

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

Copy link

melvin-bot bot commented Jan 29, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.32-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 2024-02-05. 🎊

@francoisl francoisl removed the DeployBlockerCash This issue or pull request should block deployment label Jan 29, 2024
@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Jan 31, 2024
@melvin-bot melvin-bot bot changed the title [HOLD for payment 2024-02-05] IOU - CMD+Enter command does not work when selecting currency [HOLD for payment 2024-02-07] [HOLD for payment 2024-02-05] IOU - CMD+Enter command does not work when selecting currency Jan 31, 2024
Copy link

melvin-bot bot commented Jan 31, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.33-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 2024-02-07. 🎊

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Feb 5, 2024
Copy link

melvin-bot bot commented Feb 7, 2024

Skipping the payment summary for this issue since all the assignees are employees or vendors. If this is incorrect, please manually add the payment summary SO.

@melvin-bot melvin-bot bot added the Overdue label Feb 7, 2024
@cristipaval
Copy link
Contributor

This is a regression fixed and reviewed by the contributors who worked on the original PR. No payment due here.

@melvin-bot melvin-bot bot removed the Overdue label Feb 7, 2024
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 Daily KSv2 Engineering
Projects
None yet
Development

No branches or pull requests

7 participants