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-09-20] [$1000] FAB menu - Pressing Enter doesn't open the selected option page #26228

Closed
1 of 6 tasks
izarutskaya opened this issue Aug 29, 2023 · 34 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 External Added to denote the issue can be worked on by a contributor

Comments

@izarutskaya
Copy link

izarutskaya commented Aug 29, 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:

  1. Click plus button.
  2. Use arrow up to select the option, press Enter.
  3. Notice that sometimes it doesn't open the page after pressing Enter.

Expected Result:

After pressing Enter, it should open selected option.

Actual Result:

Pressing Enter doesn't open the selected option page

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: v1.3.57-5

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

Screen.Recording.2023-08-22.At.15.43.41.mp4
bandicam.2023-08-29.01-40-15-309.mp4

Expensify/Expensify Issue URL:

Issue reported by: @hungvu193

Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1692694374144279

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~013ca232e37db3db0d
  • Upwork Job ID: 1696891737295454208
  • Last Price Increase: 2023-08-30
  • Automatic offers:
    • jjcoffee | Reviewer | 26517050
    • dukenv0307 | Contributor | 26517052
    • hungvu193 | Reporter | 26517053
@izarutskaya izarutskaya added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Aug 29, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 29, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Aug 29, 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

@dukenv0307
Copy link
Contributor

Proposal

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

FAB menu - Pressing Enter doesn't open the selected option page

What is the root cause of that problem?

we're updating we're updating selectedItemIndex state here

setSelectedItemIndex(index);

And when the modal hides, we should execute the onSelected of the corresponding item

onModalHide={() => {
setFocusedIndex(-1);
if (selectedItemIndex !== null) {
props.menuItems[selectedItemIndex].onSelected();
setSelectedItemIndex(null);
}
}}

But at that time, the selectedItemIndex is not updated yet, so we can't open the RHP

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

We don't use selectedItemIndex for rendering purpose, so we just need to use useRef

    const selectedItemIndex = useRef(null);

and update other places to use selectedItemIndex.current

@flaviadefaria flaviadefaria added the External Added to denote the issue can be worked on by a contributor label Aug 30, 2023
@melvin-bot melvin-bot bot changed the title FAB menu - Pressing Enter doesn't open the selected option page [$1000] FAB menu - Pressing Enter doesn't open the selected option page Aug 30, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 30, 2023

Job added to Upwork: https://www.upwork.com/jobs/~013ca232e37db3db0d

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

melvin-bot bot commented Aug 30, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Aug 30, 2023

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

@joh42
Copy link
Contributor

joh42 commented Aug 30, 2023

Proposal

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

The first time we press enter with the FAB menu, the page of the selected option is not opened.

What is the root cause of that problem?

The root cause of this is that when an option has been selected, we first set selectedItemIndex in the selectItem function:

const selectItem = (index) => {
const selectedItem = props.menuItems[index];
props.onItemSelected(selectedItem, index);
setSelectedItemIndex(index);
};

And then we actually open the selected item when the modal closes:

onModalHide={() => {
setFocusedIndex(-1);
if (selectedItemIndex !== null) {
props.menuItems[selectedItemIndex].onSelected();
setSelectedItemIndex(null);
}
}}

But the selectedItemIndex does not have time to update before the modal closes. This is why the wrong option is opened if we select another option and press enter - selectedItemIndex has been set to the old index but not the new one.

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

Unless I have missed something, there is no reason to split the code this way.

selectedItemIndex is only used by the selectItem function and onModalHide. And selectItem is always called when an item is selected (IE both when we select by pressing enter and when a MenuItem fires onPress).

We can clean things up quite a bit by calling the selected option's onSelected method right in the selectItem function.

This way, we do not have to worry about if selectedItemIndex has been updated to the correct value, because we can remove selectedItemIndex altogether.

The steps to implement this would be:

  1. Remove the definition of selectedItemIndex
  2. Replace setSelectedItemIndex with selectedItem.onSelected() in the selectItem function
  3. Remove the conditional checking if selectedItemIndex is not equal to null in onModalHide

It's worth noting that we still want to clear the focused index in onModalHide, in case the user closed the FAB without selecting any of the options.

selectItem would now look like this:

const selectItem = (index) => {
    const selectedItem = props.menuItems[index];
    props.onItemSelected(selectedItem, index);
    selectedItem.onSelected();
};

And onModalHide like this:

onModalHide={() => {
    setFocusedIndex(-1);
}}

What alternative solutions did you explore? (Optional)

@davewish
Copy link

Proposal


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

In the FAB menu , when Enter is pressed , it does not open selected Item

What is the root cause of that problem?

The root cause of the issue is in the selectItem function , onSelectedItem Prop , which call hideCreateMenu but it does not call onSelect function , then selectedItemIndex is set .

const selectItem = (index) => {
const selectedItem = props.menuItems[index];
props.onItemSelected(selectedItem, index);
setSelectedItemIndex(index);
};

const hideCreateMenu = useCallback(
() => {

when second time enter is pressed , onModalHide is executed ,selectedItemIndex with previous item .
onModalHide={() => {
setFocusedIndex(-1);
if (selectedItemIndex !== null) {
props.menuItems[selectedItemIndex].onSelected();
setSelectedItemIndex(null);
}
}}

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

we should update the selectItem function as follow , selectedItemIndex state is no needed .

 const selectItem = (index) => {
        const selectedItem = props.menuItems[index];
        selectedItem.onSelected()
        
    };

and update the on onModalHide

   onModalHide={() => {
                setFocusedIndex(-1);
            }}

What alternative solutions did you explore? (Optional)

N/A

@jjcoffee
Copy link
Contributor

Reviewing tomorrow!

@jjcoffee
Copy link
Contributor

jjcoffee commented Sep 1, 2023

Sorry higher priority PR review got in the way, will come back to this on Monday.

@melvin-bot melvin-bot bot added the Overdue label Sep 4, 2023
@flaviadefaria
Copy link
Contributor

Waiting for @jjcoffee's review today/tomorrow.

@melvin-bot melvin-bot bot removed the Overdue label Sep 4, 2023
@jjcoffee
Copy link
Contributor

jjcoffee commented Sep 4, 2023

Happy to go with @dukenv0307's proposal! It has the correct RCA and a good solution that cuts back usage of useState which we like!

🎀👀🎀 C+ reviewed

@melvin-bot
Copy link

melvin-bot bot commented Sep 4, 2023

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

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

melvin-bot bot commented Sep 6, 2023

📣 @jjcoffee 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

@melvin-bot
Copy link

melvin-bot bot commented Sep 6, 2023

📣 @dukenv0307 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer 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 📖

@melvin-bot
Copy link

melvin-bot bot commented Sep 6, 2023

📣 @hungvu193 🎉 An offer has been automatically sent to your Upwork account for the Reporter role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

@melvin-bot melvin-bot bot added the Weekly KSv2 label Sep 6, 2023
@dukenv0307
Copy link
Contributor

@jjcoffee The PR is ready for review

@jjcoffee
Copy link
Contributor

jjcoffee commented Sep 6, 2023

Thanks, reviewing tomorrow!

@melvin-bot
Copy link

melvin-bot bot commented Sep 11, 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 @dukenv0307 got assigned: 2023-09-06 00:35:27 Z
  • when the PR got merged: 2023-09-11 03:29:51 UTC
  • days elapsed: 3

On to the next one 🚀

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Sep 13, 2023
@melvin-bot melvin-bot bot changed the title [$1000] FAB menu - Pressing Enter doesn't open the selected option page [HOLD for payment 2023-09-20] [$1000] FAB menu - Pressing Enter doesn't open the selected option page Sep 13, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Sep 13, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 13, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 13, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.68-17 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-09-20. 🎊

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 13, 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:

  • [@jjcoffee] The PR that introduced the bug has been identified. Link to the PR:
  • [@jjcoffee] 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:
  • [@jjcoffee] 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:
  • [@jjcoffee] Determine if we should create a regression test for this bug.
  • [@jjcoffee] 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.
  • [@flaviadefaria] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@jjcoffee
Copy link
Contributor

@jjcoffee
Copy link
Contributor

Regression Test Proposal

  1. Open the FAB.
  2. Use the keyboard arrows to select an option, and press Enter.
  3. Verify that the correct page opens in the RHP.

Do we agree 👍 or 👎

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Sep 19, 2023
@jjcoffee
Copy link
Contributor

Just noting that this one was approved within 3WD, so technically due the timeliness bonus (slight extra delay was due to the merge freeze). cc @flaviadefaria

@melvin-bot melvin-bot bot added the Overdue label Sep 22, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 25, 2023

@Beamanator, @jjcoffee, @flaviadefaria, @dukenv0307 Huh... This is 4 days overdue. Who can take care of this?

@flaviadefaria
Copy link
Contributor

flaviadefaria commented Sep 26, 2023

For reference, here are some details about the assignees on this issue:
@jjcoffee requires payment offer (Reviewer)
@dukenv0307 requires payment offer (Contributor)
@hungvu193 requires payment offer (Reporter)

Payment details:
@jjcoffee = $1000 + 50% = $1500
@dukenv0307 =$1000 + 50% = $1500
@hungvu193 = $50

@melvin-bot melvin-bot bot removed the Overdue label Sep 26, 2023
@flaviadefaria
Copy link
Contributor

Everyone has been paid.

@hungvu193
Copy link
Contributor

Everyone has been paid.

@flaviadefaria Can you please update the reporting bonus to 250$?

@flaviadefaria
Copy link
Contributor

flaviadefaria commented Sep 26, 2023

But the offer was initially sent and accepted with $50, which is the new amount we're paying.

@hungvu193
Copy link
Contributor

hungvu193 commented Sep 26, 2023

Yup, that's the bot mistake, this issue was opened on 29 Aug, the bounty was adjust after 31 Aug. So it should be 250$ for the bounty.

Screenshot 2023-09-26 at 17 09 05

@flaviadefaria
Copy link
Contributor

Got it, I have paid $50 already so sent you a new offer fo the remaining $200.

@hungvu193
Copy link
Contributor

Got it, I have paid $50 already so sent you a new offer fo the remaining $200.

Thank you 😄

@flaviadefaria
Copy link
Contributor

Everyone has been paid, so closing this!

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 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

8 participants