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

[Needs regression test steps] [$1000] When copy pasting message containing email/links, email address/link occupies new line. #9250

Closed
mvtglobally opened this issue May 31, 2022 · 126 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 Improvement Item broken or needs improvement. Internal Requires API changes or must be handled by Expensify staff Reviewing Has a PR in review

Comments

@mvtglobally
Copy link

mvtglobally commented May 31, 2022

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:

Typed a message a@mail.com is my email. b@mail.com is someone else's email.
Copied and pasted in the text box below

Expected Result:

Text should copy in the same line

Actual Result:

When copy pasting message containing email/links, email address/link occupies new line.

Workaround:

unknown

Platform:

Where is this issue occurring?

  • Web
  • Desktop App

Version Number: 1.1.69-2
Reproducible in staging?: Y
Reproducible in production?: Y
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
Screenshot 2022-05-26 at 12 19 53 PM

Expensify/Expensify Issue URL:
Issue reported by: @MonilBhavsar
Slack conversation: https://expensify.slack.com/archives/C01GTK53T8Q/p1653548218883739

Job Post: https://www.upwork.com/jobs/~01e09832b6e53bb854

View all open jobs on GitHub

@melvin-bot
Copy link

melvin-bot bot commented May 31, 2022

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

@Julesssss
Copy link
Contributor

Reproduced, this should be fixed.

@Julesssss Julesssss added the External Added to denote the issue can be worked on by a contributor label Jun 1, 2022
@melvin-bot
Copy link

melvin-bot bot commented Jun 1, 2022

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

@Julesssss Julesssss added Daily KSv2 Improvement Item broken or needs improvement. and removed Daily KSv2 labels Jun 1, 2022
@melvin-bot melvin-bot bot added Weekly KSv2 and removed Daily KSv2 labels Jun 2, 2022
@melvin-bot
Copy link

melvin-bot bot commented Jun 2, 2022

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jun 2, 2022
@melvin-bot
Copy link

melvin-bot bot commented Jun 2, 2022

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

@melvin-bot melvin-bot bot changed the title When copy pasting message containing email/links, email address/link occupies new line. [$250] When copy pasting message containing email/links, email address/link occupies new line. Jun 2, 2022
@luacmartins
Copy link
Contributor

Hmm I wonder why I got assigned if @Julesssss is an ECM and is still assigned as well 🤔 @Julesssss should I keep myself assigned to this one?

@Julesssss
Copy link
Contributor

Odd, I was OOO but I didn't think auto-assignment was smart enough to know that? Anyway, I'll keep it 👍

@parasharrajat
Copy link
Member

You can do this. Please share your proposal.

@NehaSantani
Copy link

NehaSantani commented Jun 7, 2022

Proposals :

Hey,
There is a method in CopySelectionHelper.js file

 copySelectionToClipboard() {
      const selectionMarkdown = SelectionScraper.getAsMarkdown();
      Clipboard.setString(selectionMarkdown);
  }

const getAsMarkdown = () => {
    const selectionHtml = getHTMLOfSelection();
    console.log("getMarkdown",selectionHtml);

    const domRepresentation = parseDocument(selectionHtml);
    domRepresentation.children = _.map(domRepresentation.children, c => replaceNodes(c));

    const newHtml = render(domRepresentation);

    const parser = new ExpensiMark();

    return parser.htmlToMarkdown(newHtml);
};

Above method is converting the copied text to HTML then to markdown.

There are two options we can have to solve this issue:

1.) We can update the getHtmlOfSelection() for selected text which is being used while converting it into markdown as below

const getHTMLOfSelection=()=>{
   if (window.getSelection) {
       const selection = window.getSelection().toString();
       const parser = new ExpensiMark();
       return parser.replace(selection);  
    }

     // If browser doesn't support Selection API, returns empty string.
     return '';
  
}

since, parser.replace() method is already being used in while we are trying to edit a comment, we can use the same method for selection !

2.) We can set the selected text in clipboard as a plain text which is being selected by updating copySelectionToClipboard() method as below.

copySelectionToClipboard() {
      if(window.getSelection())
       Clipboard.setString(window.getSelection().toString());
   }

or by updating current getHTMLOfSelection() as returning

             return div.innerText;

instead of

            return div.innerHTML;

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jun 7, 2022
@parasharrajat
Copy link
Member

parasharrajat commented Jun 8, 2022

Hey @NehaSantani, thanks for the proposal. Did you test this solution on local setup?

How will you convert the text to Markdown?

@NehaSantani
Copy link

Hi @parasharrajat,
The text is being converted into MarkDown in the similar manner like it is currently there using below method

index.js in /SelectionScraper.js

const getAsMarkdown = () => {
    const selectionHtml = getHTMLOfSelection();

    const domRepresentation = parseDocument(selectionHtml);
    domRepresentation.children = _.map(domRepresentation.children, c => replaceNodes(c));

    const newHtml = render(domRepresentation);

    const parser = new ExpensiMark();

    return parser.htmlToMarkdown(newHtml);
};

which inturn is called from below method

 copySelectionToClipboard() {
        const selectionMarkdown = SelectionScraper.getAsMarkdown();
        Clipboard.setString(selectionMarkdown);
    }

The whole conversion currently in the code is going like this
(selectedText -----> HTML ------> Markdown)

However, the issue is inside HTML conversion of text!
Actual Issue: The code done inside getHTMLOfSelection() method is returning HTML with some default style tags which is appending it to next line after converting into markdown.

The only change we need to do to solve the issue mentioned is inside getHTMLOfSelection() method which is called from getAsMarkdown() method.

Updated getHTMLofSelection().

index.js in /SelectionScaper.js

const getHTMLOfSelection = () => {
    if (window.getSelection()) {
    const selection = window.getSelection().toString();
    const parser = new ExpensiMark();
    return parser.replace(selection);  
 }  // If browser doesn't support Selection API, returns empty string.
 return '';
}

My proposal to use above code in getHTMLOfSelection() method is because we are already using parser.replace to convert it to html while editing a message!

Also,Yes i tested it in local.
attached is the Recording for the same.

L1Screen.Recording.2022-06-09.at.9.29.34.AM.mov

@parasharrajat
Copy link
Member

Try this to copy chat between two messages. Start from bottom to the third last line(Hi Neha) of the previous message. Then paste it on composer and let me know what output you get.

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Dec 9, 2022
@Zvukamar
Copy link

Zvukamar commented Dec 9, 2022

Proposal:

In src/components/Composer/index.js

Line 222:

Change this:
const pastedHTML = event.clipboardData.getData(TEXT_HTML);

To this:
const pastedHTML = event.clipboardData.getData(TEXT_HTML).replace(/div/g, 'span');

Explain:
event.clipboardData.getData(TEXT_HTML) returns <comment><div>abc</div><span>abc</span><div>abc</div</comment>

In render each <div> by default get style of display: "block" and catch all the row,
because of that we have \n in plain text
If we replace all <div> elements with <span> elements all works good.

Tested all the cases above, everything seems good.

@ahmdshrif
Copy link
Contributor

@ahmdshrif you're assigned now. please feel free to raise PR.

I am working on it

@ahmdshrif please apply. Thanks!

@kevinksullivan done. Thanks all.

@aimane-chnaif
Copy link
Contributor

Testing blocked on web, mWeb because of this known issue (403 auth error)

@melvin-bot melvin-bot bot removed the Overdue label Dec 13, 2022
@trjExpensify
Copy link
Contributor

Commented here, but you should be able to get unblocked here now after whitelisting. 👍

@aimane-chnaif
Copy link
Contributor

ok, @ahmdshrif please fill out the form too so you could complete PR.

@ahmdshrif
Copy link
Contributor

I fill out the form. and wait to add me to the whitelist.

@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 Daily KSv2 labels Dec 14, 2022
@melvin-bot melvin-bot bot changed the title [$1000] When copy pasting message containing email/links, email address/link occupies new line. [HOLD for payment 2022-12-27] [$1000] When copy pasting message containing email/links, email address/link occupies new line. Dec 20, 2022
@melvin-bot
Copy link

melvin-bot bot commented Dec 20, 2022

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.2.41-4 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 2022-12-27. 🎊

After the hold period, please check if any of the following need payment for this issue, and if so check them off after paying:

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

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 Dec 20, 2022

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:

  • [@aimane-chnaif / @Julesssss] The PR that introduced the bug has been identified. Link to the PR:
  • [@aimane-chnaif / @Julesssss] 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:
  • [@aimane-chnaif / @Julesssss] 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:
  • [@kevinksullivan] A regression test has been added or updated so that the same bug will not reach production again. Link to the GH issue for creating the test here:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Dec 26, 2022
@aimane-chnaif
Copy link
Contributor

I think @kevinksullivan is OOO till Jan 4.
@mallenexpensify can you please help with payment here?

@aimane-chnaif
Copy link
Contributor

There was a few days delay until PR complete due to login issue on web.
Is this considerable in timeline calculation?

@mallenexpensify
Copy link
Contributor

Gotcha covered @aimane-chnaif , @ahmdshrif too!
Thanks @aimane-chnaif for stepping in to get this over the finish line and for @ahmdshrif for being extra patient with us. Thanks to the other contributors who submitted proposals and commented too!

@aimane-chnaif I did a quick check of the timeline but didn't factor in down time with IP issues. I'm seeing

  • Hired Dec 9th
  • Merged 16th

I'm seeing this post on 12/13 about the IP issue, with the 10th and 11th being weekend days, it makes sense that y'all might be affected by the issue. @aimane-chnaif and/or @ahmdshrif, if you were affected, can you provide some details/links and reasoning in a post so we can have it for audit purposes? It doesn't have to be detailed and we only need one of you to do it. Thx

@aimane-chnaif
Copy link
Contributor

aimane-chnaif commented Dec 29, 2022

@ahmdshrif created draft PR on Dec 10

  • commented on Dec 10 that ip blocked and couldn't login
  • commented on Dec 14 that still waiting for ip whitelist
    So at least 2 business days because of login issue
    cc @mallenexpensify

@aimane-chnaif
Copy link
Contributor

IP issue happened before Dec 10 and I found out @ahmdshrif's comment on slack on Dec 10

@mallenexpensify
Copy link
Contributor

Thanks for the breakdown @aimane-chnaif, I agree. I have issued 50% bonuses to you and @ahmdshrif .

Leaving open for regression test steps/BZ check list

@mallenexpensify mallenexpensify changed the title [HOLD for payment 2022-12-27] [$1000] When copy pasting message containing email/links, email address/link occupies new line. [Needs regression test steps] [$1000] When copy pasting message containing email/links, email address/link occupies new line. Dec 29, 2022
@melvin-bot
Copy link

melvin-bot bot commented Jan 5, 2023

@Julesssss, @ahmdshrif, @kevinksullivan, @aimane-chnaif Whoops! This issue is 2 days overdue. Let's get this updated quick!

@kevinksullivan
Copy link
Contributor

Still climbing through the OOO backlog, will knock this out tomorrow AM.

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 Improvement Item broken or needs improvement. Internal Requires API changes or must be handled by Expensify staff Reviewing Has a PR in review
Projects
None yet
Development

No branches or pull requests