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-06] [$1000] Android - Clicking on different option quickly opens many tabs #23867

Closed
1 of 6 tasks
kbecciv opened this issue Jul 29, 2023 · 44 comments
Closed
1 of 6 tasks
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

@kbecciv
Copy link

kbecciv commented Jul 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 at your avatar
  2. Click on different option quickly

Expected Result:

The app should opens only the first clicked option

Actual Result:

The app opens all the clicked options

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.47-2
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_20230728-231420.mp4
Screen_Recording_20230729_132217_New.Expensify.mp4

Expensify/Expensify Issue URL:
Issue reported by: @muxriddinmuqimov77
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1688707995939759

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~016e037ea65271ad6b
  • Upwork Job ID: 1686148949072994304
  • Last Price Increase: 2023-07-31
  • Automatic offers:
    • tienifr | Contributor | 26033117
    • mejed-alkoutaini | Reporter | 26033119
@kbecciv kbecciv added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jul 29, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 29, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jul 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

@ahmdshrif
Copy link
Contributor

ahmdshrif commented Jul 29, 2023

Proposal

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

click on two options quickly in the settings, two pages open simultaneously due to multiple navigation actions being fired

What is the root cause of that problem?

two navigation actions are triggered in quick succession, and we don't have a mechanism in place to prevent multiple navigations from happening simultaneously.

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

Instead of directly calling the navigation function as shown in the code snippet below:

action: () => {
Navigation.navigate(ROUTES.SETTINGS_SHARE_CODE);
},

We will create a new debounced navigation function that ensures the navigation is not called multiple times within a short period. This will prevent rapid and unintended navigation.

constructor(props) {
      this.navigate = _.debounce(this.navigate.bind(this), 300);
...
}  

navigate(route) {
    Navigation.navigate(route);
}      

...
 action: () => {
    // add to all actions
    thsi.navigate(ROUTES.SETTINGS_SHARE_CODE);
}        

What alternative solutions did you explore? (Optional)

we can introduce a disableOptionForNavigation flag to prevent the navigation function from being called again while the previous navigation is still being processed. This flag should be set to true when the first navigation is triggered and reset to false when the setting focus change (if blurred mean navigation is complete )

componentDidUpdate(prevProps) {
// if focus change we need to reset flage
    if (this.props.isFocused !== prevProps.isFocused && this.disableOptionForNavigation ) {
        this.disableOptionForNavigation = false;
    }
}

const NavigateWithDisable  (route ) {
  if (this.disableOptionForNavigation){
      return;
  }
  Navigation.navigate(route);
  this.this.disableOptionForNavigation = true;
}

@melvin-bot melvin-bot bot added the Overdue label Jul 31, 2023
@mallenexpensify mallenexpensify added the External Added to denote the issue can be worked on by a contributor label Jul 31, 2023
@melvin-bot melvin-bot bot changed the title Android - Clicking on different option quickly opens many tabs [$1000] Android - Clicking on different option quickly opens many tabs Jul 31, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 31, 2023

Job added to Upwork: https://www.upwork.com/jobs/~016e037ea65271ad6b

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

melvin-bot bot commented Jul 31, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jul 31, 2023

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

@mallenexpensify
Copy link
Contributor

Was able to repro on Daniel Silva's phone, I wasn't able to via BrowserStack. Seems like an External issue...

@melvin-bot melvin-bot bot removed the Overdue label Jul 31, 2023
@tienifr
Copy link
Contributor

tienifr commented Aug 1, 2023

Proposal

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

The app opens all the clicked options

What is the root cause of that problem?

We're not preventing users from selecting other options when the first option's navigation is in progress.

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

This issue has happened before, but for the PressableWithFeedback, let's look at how it's handled here.

This problem is the same, just that it does not apply to one single element, but a menu, where we only want 1 execution to complete before another one, so I propose that we address them with a general solution.

  1. We can create a hook useSingleExecution, which will have similar logic to here, like follow
const useSingleExecution = () => {
    const [isExecuting, setIsExecuting] = useState(false);

    const singleExecution = useCallback((action) => () => {
        if (isExecuting) {
            return;
        }

        setIsExecuting(true);

        const execution = action();
        InteractionManager.runAfterInteractions(() => {
            if (!(execution instanceof Promise)) {
                setIsExecuting(false);
                return;
            }
            execution.finally(() => {
                setIsExecuting(false);
            });
        });
    }, [isExecuting]);

    return { isExecuting, singleExecution }
}

What this will do is, with any action passed in, it will only allow 1 such action to occur at a time. This is the same approach we're already using for the PressableWithFeedback, but now we're applying it to more places with a general solution

  1. Then in here, we can add:
    const { isExecuting, singleExecution } = useSingleExecution();
    and pass to the MenuItem
disabled={isExecuting}
onPress={singleExecution(item.action)}

With this, only 1 MenuItem clicks will happen at a time, and the rest of the MenuItem will be disabled when one is executing
3. Since Navigation.navigate is currently not a promise, we can add a hook useWaitForNavigate to convert it to a promise, to be able to use with the above.
4. (Optional) We might want to choose a different style (background color, text color) to associate with executing state of the MenuItem, rather than using the same disabled style
5. The same useSingleExecution hook can be used in PressableWithFeedback, the code there will be much cleaner

What alternative solutions did you explore? (Optional)

Other places that use MenuItem could have the issue, we can fix them using the same clean approach as above, there'll only be a few lines of code change in the main component, the heavy lifting is already abstracted well in the hook.

@muxriddinmuqimov77
Copy link

Hey @kbecciv @mananjadhav @mallenexpensify.
I told this issue a long time ago (Here is the link: https://expensify.slack.com/archives/C049HHMV9SM/p1688707995939759),
but @kbecciv left and said "Not valid bud, device is OOS". It's been happening second time (Maybe more than 2 times) with me so far and I think it's not fair. I have so many bug reports that is left as couldn't reproduce. But These days I'm seeing some of these bug reports on issues list and added to Upwork (Other bug reporter as reporter role) that was already reported by me but left as some reasons. Is this fair?

@mananjadhav

This comment was marked as outdated.

@mananjadhav
Copy link
Collaborator

mananjadhav commented Aug 3, 2023

I investigated this further. I generally would want to avoid _.debounce because it is as good as setTimeout.

I think @tienifr's approach of useSingleExecution would work. I am not too concerned about changing the styles in this issue but I would let @mallenexpensify @youssef-lr take a stab at it.

🎀 👀 🎀 C+ reviewed.

@melvin-bot
Copy link

melvin-bot bot commented Aug 3, 2023

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

@melvin-bot melvin-bot bot added the Overdue label Aug 7, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 8, 2023

@mananjadhav, @youssef-lr, @mallenexpensify Huh... This is 4 days overdue. Who can take care of this?

@youssef-lr
Copy link
Contributor

I like @tienifr's solution as well!

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

melvin-bot bot commented Aug 9, 2023

📣 @mananjadhav Please request via NewDot manual requests for the Reviewer role ($1000)

@muxriddinmuqimov77
Copy link

@mallenexpensify I didn't get paid yet.

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Sep 5, 2023
@mananjadhav
Copy link
Collaborator

@mallenexpensify This couldn't be pinpointed to a specific PR. This was an lag in the App we fixed by adding a throttling/single thread execution.

Considering this is prevalent more on Android only. I don't think we need regression test steps.

@JmillsExpensify
Copy link

$1,000 approved for payment via NewDot based on BZ summary.

@melvin-bot melvin-bot bot added the Overdue label Sep 10, 2023
@youssef-lr
Copy link
Contributor

Not overdue.

@melvin-bot melvin-bot bot removed the Overdue label Sep 11, 2023
@mallenexpensify
Copy link
Contributor

@muxriddinmuqimov77 I assumed you were the below, is that not correct?
image

@muxriddinmuqimov77
Copy link

muxriddinmuqimov77 commented Sep 11, 2023 via email

@mallenexpensify
Copy link
Contributor

Requested refund from the contributor I screenshotted above
@muxriddinmuqimov77 can you please accept the job and reply here once you have?
https://www.upwork.com/jobs/~016e037ea65271ad6b

Can you please provide a screenshot of your profile with name/avatar so I can be sure to pay the correct person. Thx

@muxriddinmuqimov77
Copy link

Requested refund from the contributor I screenshotted above @muxriddinmuqimov77 can you please accept the job and reply here once you have? https://www.upwork.com/jobs/~016e037ea65271ad6b

Can you please provide a screenshot of your profile with name/avatar so I can be sure to pay the correct person. Thx

Sure. Here it's.
image

When you submit an offer to the job, I'll accept it. Thanks

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

Hey @mallenexpensify. Any updates?

@mallenexpensify
Copy link
Contributor

@muxriddinmuqimov77 hired, can you please accept the job and reply here once you have?
https://www.upwork.com/jobs/~016e037ea65271ad6b
In the future, it's easier/better/faster if you apply via the job link when it's first posted (if you're not auto-hired via API) then for us to extend the job to you then have you accept then we have to pay.

@melvin-bot melvin-bot bot removed the Overdue label Sep 14, 2023
@mallenexpensify
Copy link
Contributor

@mejed-alkoutaini I figured out the issue!
This issue was originally created with you as the bug reported. It was then updated to @muxriddinmuqimov77 because they reported the bug before you
image

vs
image

That said... @muxriddinmuqimov77 's bug reported wasn't acted up so, if you hadn't reported the bug again, we wouldn't have fixed it. Therefore, I think it's fair to compensate for reporting the bug, you don't need to approve the refund I requested.

reminder to self, payment owed is $250 for @muxriddinmuqimov77 for reporting, I think I hired them for $1000 by mistake.

@muxriddinmuqimov77
Copy link

@mallenexpensify Will you send updated offer or update the amount after I accept the offer?

@mallenexpensify
Copy link
Contributor

New offer sent for $250 @muxriddinmuqimov77 !

@muxriddinmuqimov77
Copy link

@mallenexpensify Accepted. Thanks!

@mejed-alkoutaini
Copy link

@mallenexpensify I approved the refund 2 days ago, can you create a new milestone for it ?

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

melvin-bot bot commented Sep 18, 2023

@mananjadhav, @youssef-lr, @mallenexpensify, @tienifr Whoops! This issue is 2 days overdue. Let's get this updated quick!

@mallenexpensify
Copy link
Contributor

Final payment recap
Issue reporter: @mejed-alkoutaini paid $250 via Upwork (reasoning above)
Issue reporter: @muxriddinmuqimov77 paid $250 via Upwork
Contributor: @tienifr paid $1000 via Upwork
Contributor+: @mananjadhav is due or paid $1000 via NewDot (I'm uncertain which, @JmillsExpensify approved the payment last week)

@mejed-alkoutaini , I issued you a bonus on the original contract so it should show up for you, thanks for the patience.

Finally.... @mananjadhav , can you please fill out the BZ checklist above from above so we can get this issue closed?

@melvin-bot melvin-bot bot removed the Overdue label Sep 19, 2023
@mananjadhav
Copy link
Collaborator

@mallenexpensify Please check my comment here. Let me know if you need further information.

@melvin-bot melvin-bot bot added the Overdue label Sep 25, 2023
@mallenexpensify
Copy link
Contributor

Thanks @mananjadhav , closing

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

9 participants