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

Fix: (Redo) Copying the messages and marking a message in between as unread generates 'new' in the text #18684

Conversation

Victor-Nyagudi
Copy link
Contributor

@Victor-Nyagudi Victor-Nyagudi commented May 9, 2023

Details

This is a redo of my original pull request that caused a regression but was reverted as soon as it was discovered.

This time, I've added the styles.userSelectNone style to UnreadActionIndicator so users are visually aware it's not copied to the clipboard and then removed this element alone from the copied contents inside SelectionScraper.

We agreed this is the best way forward considering there's still much to do in handling all issues of copying and pasting in addition to another copying bug found in browsers.

It's worth noting there's another currently open issue where copying messages with one unread message in between generates <_a Icon> in the text, however, this is still happening in staging even after my PR was reverted, so I suspect another PR may have caused it - not sure which one, though.

That being said, I didn't see this behavior in my current PR, so this PR might address that too.

Fixed Issues

$ #17838
$ #18228 (comment)

Tests

Please note that if you left-click and drag from the left to right/top right/bottom right of a chat i.e. place the cursor to the left of the chat profile image and drag to select, the emojis are not copied. If you left click and drag from the right side to left/top left/bottom left i.e. place cursor to the right of chat text (the large empty area to the right of a chat) and drag to select, the emojis are also copied.

  1. Log in with an account that has at least one chat created on Mac Chrome/Mac Safari/Mac Desktop
  2. Click on any chat
  3. Send multiple messages e.g. 1, 2, 3, 4, 5, 6
  4. Select a message in between e.g. 4 and mark it as unread (make sure a green line appears after marking as unread, otherwise, try refreshing the page and mark as unread again)
  5. Copy all the messages i.e. left-click and drag over all the messages then copy (Cmd/Ctrl + C)
  6. Verify the word New that's to the right of the green line is not highlighted
  7. Paste the selection in the composer i.e. Cmd/Ctrl + V
  8. Verify the word New is not part of pasted content
  9. Click on a separate chat and then come back to the one with the unread message to update its status to read
  10. Copy and paste all the messages into the composer like before
  11. Verify that pasted content is the same as what's copied i.e. works as usual
  12. Click on the avatar to the top left of the screen i.e. the one with your profile picture.
  13. Click Preferences and then Language. Change the language to Spanish.
  14. Repeat steps 2-11.
  • Verify that no errors appear in the JS console

Offline tests

Same as above but go offline after logging in i.e. step 1 (or force offline in staging).

QA Steps

Same as Tests.

Please note that if you try to select all by using the toolbar i.e. Edit -> Select All, copy, and then paste into the composer, there's a good chance you'll open the Send Attachment modal/page. This is a bug I reported recently, so please be aware of this behavior.

Additional steps

  1. After performing the steps in Tests, click on the unread message and edit it to something like 4.5.
  2. Copy the messages & paste into the composer.
  3. Verify New text is not highlighted nor pasted in composer.
  4. Click the + sign in the composer and choose Request Money.
  5. Enter an amount and optional description and then click the green request button at the bottom.
  6. Mark the chat comment with the money request as unread and refer to steps 2 & 3.
  7. Repeat steps 4-6 with the Send Money option. The green button at the bottom will have different text e.g. I'll settle up elsewhere, but that's fine.
  8. Delete the Request Money chat, mark the deleted chat as unread, and then do steps 2 & 3.
  9. Click outside the composer to blur it, and then select all with Cmd + A(see above for unintended behavior when selecting all). Perform steps 2 & 3.
  10. Click the + sign in the composer and select Add attachment.
  11. Upload an image/video.
  12. Mark the chat with the attachment as unread and then perform steps 2 & 3.
  13. Edit the messages you've sent so far and perform steps 2 & 3.
  14. Try triple-clicking the New word to the right of the green line (if you can) and perform steps 2 & 3.
  15. Repeat all these steps in a group chat with multiple participants.
  16. Repeat all these steps after changing the language to Spanish.
  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Web

Chrome Spanish
expensify-mac-chrome-spanish-new-text-not-copied

Chrome English
expensify-mac-chrome-english-new-text-not-copied

Safari Spanish
expensify-mac-safari-spanish-new-text-not-copied

Safari English
expensify-mac-safari-english-new-text-not-copied

Mobile Web - Chrome

expensify-mobile-chrome-web-screenshot

Mobile Web - Safari

expensify-mobile-safari-web-screenshot

Desktop

English
expensify-mac-desktop-english-new-text-not-copied

Spanish
expensify-mac-desktop-spanish-new-text-not-copied

iOS

expensify-ios-native-screenshot

Android

expensify-android-native-screenshot

@Victor-Nyagudi Victor-Nyagudi marked this pull request as ready for review May 9, 2023 23:27
@Victor-Nyagudi Victor-Nyagudi requested a review from a team as a code owner May 9, 2023 23:27
@melvin-bot melvin-bot bot requested review from Beamanator and fedirjh and removed request for a team May 9, 2023 23:27
@melvin-bot
Copy link

melvin-bot bot commented May 9, 2023

@Beamanator @fedirjh One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@fedirjh
Copy link
Contributor

fedirjh commented May 10, 2023

cc @Victor-Nyagudi you need to pull main and run npm run prettier, we just added Prettier into the App codebase , and that's will affect anyone with open PRs. check this conversation https://expensify.slack.com/archives/C01GTK53T8Q/p1683669159014609

Copy link
Contributor

@fedirjh fedirjh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test good , left some suggestions

@fedirjh
Copy link
Contributor

fedirjh commented May 10, 2023

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Web
Screen.Recording.2023-05-10.at.1.53.37.AM.mov
Mobile Web - Chrome

Screenshot_1683679531

Mobile Web - Safari

Simulator Screenshot - iPhone 14 - 2023-05-10 at 01 49 13

Desktop
Screen.Recording.2023-05-10.at.1.52.27.AM.mov
iOS

Simulator Screenshot - iPhone 14 - 2023-05-10 at 01 46 54

Android

Screenshot_1683679558

@Victor-Nyagudi
Copy link
Contributor Author

Victor-Nyagudi commented May 10, 2023

I've merged this PR with main that now has Prettier and added @fedirjh suggestions.

I also ran npm run prettier.

Let me know if you need anything else.

cc: @Beamanator @fedirjh

@Beamanator
Copy link
Contributor

Umm @Victor-Nyagudi this looks very scary, can you make sure your branch is up to date with main?

Screenshot 2023-05-10 at 12 48 49 PM

Also looks like there's another conflict

@Victor-Nyagudi
Copy link
Contributor Author

Victor-Nyagudi commented May 10, 2023

@Beamanator At the time of posting my comment, my branch was up to date with main. After pulling the Prettier changes to my main branch and merging it with this PR, all those 700+ files were changed.

I figured this is what would happen since running npm run prettier would format files. How do you advise moving forward?

I see there are currently some commits already as we speak, so I'll pull those.

@Victor-Nyagudi
Copy link
Contributor Author

The only changes I can see from my side that I believe caused the conflict is in UnreadActionIndicator. I'll keep them for this PR.

Thanks for pointing that out.

I'll pull from main to see if the conflicts persist.

@Victor-Nyagudi
Copy link
Contributor Author

Here's what I've done so far to give you some context on how I arrived here.

  • I created a branch, made changes, and pushed changes to the upstream branch of my fork
  • I created this PR to merge the changes to Expensify's main
  • I was alerted the PR with Prettier was merged, so I went to GitHub and synced my fork with Expensify's main
  • I used git pull to get the changes locally
  • I switched to this PR's branch and used git merge main to get the changes from main.
  • I pushed these changes upstream to my fork using git push(upstream was already set). This is what caused all the 700+ file changes
  • I added the suggested changes, committed, and pushed them to this PR's branch

Did I do something wrong in between?

I'd love to hear some feedback before proceeding any further.

@fedirjh
Copy link
Contributor

fedirjh commented May 10, 2023

@Victor-Nyagudi I believe you shouldn't do this :

I pushed these changes upstream to my fork using git push(upstream was already set). This is what caused all the 700+ file changes

Could you please revert theses changes ?

Here is a helpful guide: https://www.atlassian.com/git/tutorials/merging-vs-rebasing

@Victor-Nyagudi
Copy link
Contributor Author

Wow. I've learned so much about Git in the past hour or so.

Thank you, @fedirjh.

I've reverted the change.

What could be causing the merge conflict, though? It wasn't there on my last PR.

@fedirjh
Copy link
Contributor

fedirjh commented May 10, 2023

@Victor-Nyagudi I am happy that helped you.

What could be causing the merge conflict, though? It wasn't there on my last PR.

Could you please try to pull main again ?

@Victor-Nyagudi
Copy link
Contributor Author

Sure, @fedirjh.

Just to be clear, here are the steps I'm going to perform.

  • Sync the main branch of my fork on GitHub with Expensify so I have the latest commits
  • Run git remote update to see changes and then git pull on my local main branch to get the changes locally
  • Switch to this PR's branch with git checkout fix/17838-unread-action-indicator-text-copied
  • Run git merge main while on the PR's branch (It's at this point last time when I saw many files changed)

Does all this sound good?

@Victor-Nyagudi I believe you shouldn't do this :

I pushed these changes upstream to my fork using git push(upstream was already set). This is what caused all the 700+ file changes

Could you please revert theses changes ?

Here is a helpful guide: https://www.atlassian.com/git/tutorials/merging-vs-rebasing

Based on what you said here, I shouldn't push these changes to this PR's branch i.e. git push, correct?

@Victor-Nyagudi
Copy link
Contributor Author

By the way, @fedirjh and @Beamanator, I'm truly sorry for these hiccups we're experiencing.

I take blame for them, and I've set aside the next 3 or so uninterrupted hours (more if needed) to work together with you guys to get this PR merged.

I understand you two are busy with reviewing proposals and other internal stuff, so I'd like to get things across the line to free you up to focus on more pressing issues.

If you're not as free during this time, it's absolutely fine. I just want you know that this PR is now my top priority, and I'll be responding in a more timely manner.

@fedirjh
Copy link
Contributor

fedirjh commented May 10, 2023

@Victor-Nyagudi As I see , your branch is still behind the main 170 commits behind Expensify:main. Try to rebase your branch on top of main and then push

Screenshot 2023-05-10 at 5 37 29 PM

@Victor-Nyagudi
Copy link
Contributor Author

I was going to rebase, but I was a bit concerned about rewriting the commit history.

I'm more confident doing so after reading what you just shared.

Please stand by.

@Victor-Nyagudi
Copy link
Contributor Author

@fedirjh There are still conflicts with some other files such as IOU.js, ReportUtils.js when rebasing with main.

These are files I didn't touch but I believe were modified by Expensify's engineers/other contributors.

@Victor-Nyagudi
Copy link
Contributor Author

I'm currently discussing this with the person who announced the Prettier PR merge in Slack.

Here's the link if you want to follow the conversation, @fedirjh.
https://expensify.slack.com/archives/C01GTK53T8Q/p1683698370470619

@Victor-Nyagudi Victor-Nyagudi marked this pull request as draft May 11, 2023 05:07
@Victor-Nyagudi Victor-Nyagudi marked this pull request as ready for review May 11, 2023 08:13
@Victor-Nyagudi
Copy link
Contributor Author

As of this comment, my branch is up to date with main, and all conflicts have been resolved.

Over to you, @Beamanator and @fedirjh.

Copy link
Contributor

@Beamanator Beamanator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Victor-Nyagudi thanks so much for all your work getting this PR on track, with all the changes merged & everything 🙏

And sorry but I have one question, can we quickly discuss before we move forward with this solution?

@Victor-Nyagudi
Copy link
Contributor Author

Victor-Nyagudi commented May 13, 2023

Over to you gentlemen, @Beamanator & @fedirjh.

LGTM (I'm going to take a wild guess this acronym stands for "Let's Get This Merged")

Copy link
Contributor

@fedirjh fedirjh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

Suggested by fedirjh. Thanks for catching that.

Co-authored-by: Fedi Rajhi <[email protected]>
Copy link
Contributor

@fedirjh fedirjh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and tests well , Over to you @Beamanator

@Beamanator
Copy link
Contributor

LGTM (I'm going to take a wild guess this acronym stands for "Let's Get This Merged")

correct @Victor-Nyagudi ! 💪

Copy link
Contributor

@Beamanator Beamanator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, :shipit:

Copy link
Contributor

@Beamanator Beamanator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, :shipit:

@Beamanator Beamanator merged commit 1bb137e into Expensify:main May 15, 2023
@OSBotify
Copy link
Contributor

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

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/Beamanator in version: 1.3.14-0 🚀

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

@mvtglobally
Copy link

on step 5 when I copy messages the appeared after past with emoji reaction. Is it OK?

18684.Desktop.mp4

@fedirjh
Copy link
Contributor

fedirjh commented May 16, 2023

@mvtglobally That's a separate issue being handled here #18343 , it’s reproducible on production as well, It happens when you select text from bottom to top , check out explanation here #18343 (comment)

Screen.Recording.2023-05-16.at.11.48.11.PM.mov

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/yuwenmemon in version: 1.3.14-14 🚀

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants