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 2021-09-16] Desktop - Big empty space in message fields if copy/paste the Text from MAC Note.app #4484

Closed
kavimuru opened this issue Aug 7, 2021 · 28 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Engineering External Added to denote the issue can be worked on by a contributor Weekly KSv2

Comments

@kavimuru
Copy link

kavimuru commented Aug 7, 2021

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Issue was found when executing the PR #4363

Action Performed:

  1. Navigate to a conversation that has some messages.
  2. Paste the Text from MAC note.app to the composer.

Expected Result:

Only entered message should be visible in compose field if copy/paste the Text from MAC Note.app

Actual Result:

Big empty space in message compose field if copy/past the Text from MAC Note.app

Workaround:

Unknown

Platform:

Where is this issue occurring?

  • Desktop App

Version Number:
v1.0.83-0
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos:

Bug5182815_empty.mp4

Bug5182815_empty

Expensify/Expensify Issue URL:

View all open jobs on Upwork

@kavimuru kavimuru added the DeployBlockerCash This issue or pull request should block deployment label Aug 7, 2021
@OSBotify
Copy link
Contributor

OSBotify commented Aug 7, 2021

👋 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.

@MelvinBot
Copy link

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

@bondydaa bondydaa removed their assignment Aug 7, 2021
@bondydaa
Copy link
Contributor

bondydaa commented Aug 7, 2021

I am OOO

@francoisl
Copy link
Contributor

@parasharrajat - just checking, it looks like you were aware of this issue, correct? Was there a separate GH issue that was opened to track the bug where newlines are prepended to messages pasted into the message box?

@parasharrajat
Copy link
Member

parasharrajat commented Aug 10, 2021

No, a new issue was not opened at that time. I was waiting for #4363 to merge as only after that, this behaviour is revealed.
So with an inspection, I come to know that the Mac Note app. usages   chars to show spaces which are also needed to be escaped and current _.unescape does not do that. I think we need a custom implementation as is not made to parse HTMLEntities and its usages do not seem sufficient any more.

About the main issue, let me quickly take a good peek at it. Only then I can tell what is causing this much space.

@roryabraham
Copy link
Contributor

I think we should demote this from deploy blocker to regular-old 🐛

@roryabraham roryabraham removed the DeployBlockerCash This issue or pull request should block deployment label Aug 11, 2021
@flodnv flodnv added Weekly KSv2 and removed Hourly KSv2 labels Aug 12, 2021
@marcaaron marcaaron added Daily KSv2 and removed Weekly KSv2 labels Aug 21, 2021
@marcaaron
Copy link
Contributor

This hasn't been looked at in 9 days and has no assignee. Bumping to daily and making it External so we do something.

@marcaaron marcaaron added the External Added to denote the issue can be worked on by a contributor label Aug 21, 2021
@MelvinBot
Copy link

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

@kadiealexander
Copy link
Contributor

@parasharrajat is this related at all to #4759?

@parasharrajat
Copy link
Member

@kadiealexander #4759 is needed to improve the parsing. But I was not able to reproduce the same behavior of this issue. There is space between pasted text but not before or after.

@parasharrajat
Copy link
Member

After fixing #4759,
I get this where I see no space.

note-fix.mp4

@kadiealexander
Copy link
Contributor

What version are you working with @parasharrajat? I just tested on version 1.0.85-9 (1.0.85-9) and I still see the white space above the message:

2021-08-23_11-21-10.mp4

@parasharrajat
Copy link
Member

parasharrajat commented Aug 22, 2021

Ok. I think it's specific to chrome. Let me retest.

@kadiealexander I am on v1.0.86-4 and for me, chrome is also fine.

EDIT: it may be note.app version. My Note.app version is 4.7

Sorry I got it now. It is reproducible now.

@kadiealexander
Copy link
Contributor

kadiealexander commented Aug 22, 2021

Mine was on desktop app too, just FYI for the thread.

Thanks for helping me troubleshoot it @parasharrajat! Will post to UW now :)

@parasharrajat
Copy link
Member

I have found the fix as well. Preparing the proposal now.

@parasharrajat
Copy link
Member

parasharrajat commented Aug 23, 2021

Explanation

We faced an issue before where there were extra spaces on the Windows platform as windows surround the pasted HTML between html & body tags. Similarly, I found, in this case, the Whole valid HTML5 document is copied into the clipboard. It contains whole meta tags, head, doctype, link, and others. But Each tag contains a trailing newline for example

<html>\n
<body>\n
asdasdsadsadsad
</body>\n
</html>\n

While we trim all these extra tags but all those newlines are being prepended which creates a big empty space.

Proposal

  1. We should only parse the body tag, if present as only the body tag contains a representational text.

  2. we only use content present between body tag if body tag is present. Then apply all of our parsing rules.

  3. We don't need this rule

  {
                name: 'Strip Special Tags',
                regex: /(\n|\r\n)?<\/?(html|body)(?:"[^"]*"|'[^']*'|[^'"><])*>(?![^<]*(<\/pre>|<\/code>))(\n|\r\n)?/gim,
                replacement: ''
            },

Instead in htmlToMarkdown method we first try to find the body tag. if found we replace the original text being converted with its content.

 let generatedMarkdown = htmlString;
        const body = /<(body)(?:"[^"]*"|'[^']*'|[^'"><])*>(?:\n|\r\n)?([\s\S]*?)(?:\n|\r\n)?<\/\1>(?![^<]*(<\/pre>|<\/code>))/im;
        const parseBodyTag = generatedMarkdown.match(body);
        if(parseBodyTag){
            generatedMarkdown = parseBodyTag[2];
        }

This will trim the Extra newlines. At last, I suggest we should use a mature html-to-md parser. Otherwise, we will have many bugs like this.

@kadiealexander
Copy link
Contributor

@MelvinBot MelvinBot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Aug 23, 2021
@MelvinBot
Copy link

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

@kadiealexander
Copy link
Contributor

@johnmlee101 when you get a moment, would you mind reviewing the existing proposals here?

@johnmlee101
Copy link
Contributor

Love the proposal @parasharrajat .

@kadiealexander feel free to assign out the job!

@MelvinBot MelvinBot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Aug 26, 2021
@kadiealexander
Copy link
Contributor

@parasharrajat, I've hired you in Upwork! Please go ahead with your PR 😊

@johnmlee101
Copy link
Contributor

Bumping back to weekly while we wait for this to close out

@parasharrajat
Copy link
Member

I am on vacation. back on 8.

@botify
Copy link

botify commented Sep 8, 2021

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@botify
Copy link

botify commented Sep 8, 2021

🚀 Deployed to staging by @johnmlee101 in version: 1.0.94-2 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@botify botify added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Sep 9, 2021
@botify botify changed the title Desktop - Big empty space in message fields if copy/paste the Text from MAC Note.app [HOLD for payment 2021-09-16] Desktop - Big empty space in message fields if copy/paste the Text from MAC Note.app Sep 9, 2021
@botify
Copy link

botify commented Sep 9, 2021

🚀 Deployed to production by @yuwenmemon in version: 1.0.95-1 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@parasharrajat
Copy link
Member

@kadiealexander Any update for Upwork?

@kadiealexander
Copy link
Contributor

Sorry @parasharrajat, timezones meant this fell on my weekend! I've paid this now. 💸

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

No branches or pull requests