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-08-28] [$1000] Chat - Email is pasted twice in the composer when copied from user profile #25409

Closed
2 of 6 tasks
lanitochka17 opened this issue Aug 17, 2023 · 78 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 Engineering External Added to denote the issue can be worked on by a contributor

Comments

@lanitochka17
Copy link

lanitochka17 commented Aug 17, 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. Go to staging.new.expensify.com
  2. Open profile page for any user in chat
  3. Click Copy to clipboard icon next to the email
  4. Paste the email in the composer

Expected Result:

Email is pasted once in the composer

Actual Result:

Email is pasted twice in the composer

Workaround:

Unknown

Platforms:

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

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

Version Number: 1.3.55-1

Reproducible in staging?: Yes

Reproducible in production?: No

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

Bug6168183_bandicam_2023-08-17_22-20-02-511.mp4

Expensify/Expensify Issue URL:

Issue reported by: Applause - Internal Team

Slack conversation:

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01f8779e48a7b14b9d
  • Upwork Job ID: 1692204576618807296
  • Last Price Increase: 2023-08-17
  • Automatic offers:
    • situchan | Reviewer | 26181155
    • daordonez11 | Contributor | 26181158
@lanitochka17 lanitochka17 added the DeployBlockerCash This issue or pull request should block deployment label Aug 17, 2023
@OSBotify
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.

@melvin-bot
Copy link

melvin-bot bot commented Aug 17, 2023

Triggered auto assignment to @bondydaa (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

@situchan
Copy link
Contributor

This was first reported by me - https://expensify.slack.com/archives/C049HHMV9SM/p1692127516386599

@daordonez11
Copy link
Contributor

daordonez11 commented Aug 17, 2023

This error was introduced in this PR #23359

Proposal

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

Double paste in composer after copying email prom profile

What is the root cause of that problem?

First of all, the error only happens when the profile is opened (copy email) and then closed because it triggers the handler of navigation focus.

Then there are 2 different paste handlers at the same time, one associated to the whole document and one associated to the input

Hence handlePaste is called 2 times

useEffect(() => {
// we need to handle listeners on navigation focus/blur as Composer is not unmounting
// when navigating away to different report
const unsubscribeFocus = navigation.addListener('focus', () => document.addEventListener('paste', handlePaste));
const unsubscribeBlur = navigation.addListener('blur', () => document.removeEventListener('paste', handlePaste));
if (_.isFunction(forwardedRef)) {
forwardedRef(textInput.current);
}
if (textInput.current) {
textInput.current.addEventListener('paste', handlePaste);

PS: There is another error reading the code. If textInput.current does not exist, the first time the Composer is shown the pasted text will not go through handlePaste

Update after @situchan comment we should handle it as the class component had it before where paste was handled as a document event with document.addEventListener instead of using textInput.current

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

Both handlers should be handled the same way, either both are associated with the document to ensure the handler is removed when navigation blur is called or there is a validation to handle each case.

So instead of using textInput.current for paste we can use document for handling the paste event always

Also in the return method of the effect we should do: textInput.current.removeEventListener('paste', handlePaste); or include the same validation to remove the respective handler.

In pseudocode something like if we want to handle both:

const unsubscribeFocus = navigation.addListener('focus', () => {
            if (textInput.current) {
                textInput.current.addEventListener('paste', handlePaste);
            }
            else {
                document.addEventListener('paste', handlePaste)
            }
        });
        const unsubscribeBlur = navigation.addListener('blur', () => {
            if (textInput.current) {
                textInput.current.removeEventListener('paste', handlePaste);
            }
            else {
                document.removeEventListener('paste', handlePaste)
            }
        });

What alternative solutions did you explore? (Optional)

Validate if handlePAste is already called in some way and avoid multicall or something like throttle in the same method but too complex for a simple task

cc @mountiny

@StevenKKC
Copy link
Contributor

Proposal

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

Email is pasted twice in the composer when copied from user profile.

What is the root cause of that problem?

In Composer component, we add two paste event listener.

const unsubscribeFocus = navigation.addListener('focus', () => document.addEventListener('paste', handlePaste));

textInput.current.addEventListener('paste', handlePaste);

So the text is pasted twice in the composer.

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

We should remove one paste event listener.
Since adding event listener to textInput.current is redundant, we can remove this line.

    if (textInput.current) {
-       textInput.current.addEventListener('paste', handlePaste);

What alternative solutions did you explore? (Optional)

None.

@melvin-bot melvin-bot bot added Daily KSv2 and removed Hourly KSv2 labels Aug 17, 2023
@bondydaa bondydaa mentioned this issue Aug 17, 2023
58 tasks
@mountiny
Copy link
Contributor

@daordonez11 Are you bale to create a PR for this with a fix now? Its a deploy blocker so urgency is required.

@bondydaa would you like to let the contributor fix this?

@bondydaa bondydaa added External Added to denote the issue can be worked on by a contributor Bug Something is broken. Auto assigns a BugZero manager. labels Aug 17, 2023
@melvin-bot melvin-bot bot changed the title Chat - Email is pasted twice in the composer when copied from user profile [$1000] Chat - Email is pasted twice in the composer when copied from user profile Aug 17, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 17, 2023

Job added to Upwork: https://www.upwork.com/jobs/~01f8779e48a7b14b9d

@melvin-bot
Copy link

melvin-bot bot commented Aug 17, 2023

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

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

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

@melvin-bot
Copy link

melvin-bot bot commented Aug 17, 2023

Triggered auto assignment to @jliexpensify (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Aug 17, 2023

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

@daordonez11
Copy link
Contributor

I can definitely create a PR and work on it right now @mountiny @bondydaa

@mountiny
Copy link
Contributor

@bondydaa up to you

@getusha
Copy link
Contributor

getusha commented Aug 17, 2023

Proposal

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

Text is pasted twice when text is copied from user profile.

What is the root cause of that problem?

When navigation is focused it will add a 'paste' event listener, which makes the component have two event listeners at once triggering paste twice.

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

Prior to adding the event listener to 'textInput', initiate a call to document.removeEventListener('paste', handlePaste) in order to remove the previous event listener from the document.

What alternative solutions did you explore? (Optional)

@Expensify Expensify deleted a comment from melvin-bot bot Aug 18, 2023
@twisterdotcom twisterdotcom added Weekly KSv2 and removed Daily KSv2 labels Aug 18, 2023
@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Aug 21, 2023
@melvin-bot melvin-bot bot changed the title [$1000] Chat - Email is pasted twice in the composer when copied from user profile [HOLD for payment 2023-08-28] [$1000] Chat - Email is pasted twice in the composer when copied from user profile Aug 21, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 21, 2023

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Aug 21, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 21, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.55-8 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-08-28. 🎊

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 Aug 21, 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:

@b4s36t4
Copy link
Contributor

b4s36t4 commented Aug 22, 2023

Do I get any reporting bonus #25409 (comment) for this one?

@MitchExpensify
Copy link
Contributor

The issue in question here was reported by our internal testers. Does what @b4s36t4 commented on here look like a distinct issue to what was reporting here originally to you @situchan ?

@situchan
Copy link
Contributor

The issue in question here was reported by our internal testers. Does what @b4s36t4 commented on here look like a distinct issue to what was reporting here originally to you @situchan ?

I think he's eligible though it's not a formal bug report in slack.

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 Daily KSv2 labels Aug 28, 2023
@MitchExpensify
Copy link
Contributor

Payment summary:

Reporting: Applause N/A
C: @daordonez11 $1500 (Upwork)
C+: @situchan $1500 (Upwork)

@MitchExpensify
Copy link
Contributor

Paid and contracts ended

@MitchExpensify
Copy link
Contributor

Bump on BZ steps @situchan

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

melvin-bot bot commented Sep 1, 2023

@bondydaa, @twisterdotcom, @daordonez11, @MitchExpensify, @situchan Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@situchan
Copy link
Contributor

situchan commented Sep 1, 2023

  • The PR that introduced the bug has been identified. Link to the PR: Migrate Composer. web #23359
  • 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: Migrate Composer. web #23359 (comment)
  • 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: N/A
  • Determine if we should create a regression test for this bug.
  • 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.

Regression Test Proposal:

  1. Open any chat
  2. Open any RHP page (i.e. Settings page) and then close
  3. Copy any text
  4. Paste into the composer
  5. Verify that text is not pasted twice

@MitchExpensify I am also eligible for reporting bonus as I reported before this GH is created - #25409 (comment)

@melvin-bot melvin-bot bot removed the Overdue label Sep 1, 2023
@MitchExpensify
Copy link
Contributor

I am also eligible for reporting bonus as I reported before this GH is created - #25409 (comment)

Paid reporting bonus!

@MitchExpensify
Copy link
Contributor

Added new test request - Thanks everyone!

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

No branches or pull requests