Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.53k stars 2.88k forks source link

Chat-Copy to clipboard the image link and paste in assign task - title shown as attachment #49271

Closed IuliiaHerets closed 1 month ago

IuliiaHerets commented 1 month ago

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


Version Number: v9.0.35-0 Reproducible in staging?: Y Reproducible in production?: Y Issue reported by: Applause Internal Team

Action Performed:

  1. Launch both mweb and Android
  2. Open a chat
  3. Paste the image link in compose and send the message - ![https://hatrabbits.com/wp-content/uploads/2017/01/random.jpg] (https://hatrabbits.com/wp-content/uploads/2017/01/random.jpg)
  4. In Android, long press the message and copy to clipboard the link
  5. Paste in compose and send the message
  6. Note on pasting same link is shown
  7. Tap plus icon -- assign task
  8. Paste the link in title and description
  9. Note same link is pasted
  10. In mweb, long press the message and copy to clipboard the link
  11. Paste in compose and send the message
  12. Note on pasting same link is shown
  13. Tap plus icon -- assign task
  14. Paste the link in title and description
  15. Note instead of link , attachment text is pasted From Android, copy to clipboard and paste in mweb-title and description, link is shown. Issue reproduced only if you copy to clipboard from mweb and paste in mweb assign task title and description.

    Expected Result:

    Describe what you think should've happened

Actual Result:

Copy to clipboard the image link and paste in assign task - title&description shown as [attachment] instead of image link.

Workaround:

Unknown

Platforms:

Screenshots/Videos

https://github.com/user-attachments/assets/0b41b240-6207-4414-8345-78866fa8c8f5

View all open jobs on GitHub

melvin-bot[bot] commented 1 month ago

Triggered auto assignment to @abekkala (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

IuliiaHerets commented 1 month ago

@abekkala FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

FitseTLT commented 1 month ago

Proposal

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

Chat-Copy to clipboard the image link and paste in assign task - title shown as attachment

What is the root cause of that problem?

For native canSetHtml is false so we set the clipboard to parsed markdown here https://github.com/Expensify/App/blob/00bc167940607f1418109f00e2b4e2d7d4ae858b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx#L48 but for mWeb it is true so we are copying htmlToText of the markdown image to plain text of the clipboard https://github.com/Expensify/App/blob/00bc167940607f1418109f00e2b4e2d7d4ae858b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx#L52 which is [Attachment] and that will be pasted in normal text input, as opposed to the compose.

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

We have already dealt with the exception of anchor tags here https://github.com/Expensify/App/blob/00bc167940607f1418109f00e2b4e2d7d4ae858b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx#L52

where we copy the parsed markdown when it is an anchor tags so we similarly should check for img tag and copy the htmlToMarkdown instead of the htmlToText


        const isImgTag = /^<img([\w\W]+?)\/>$/i.test(content);
        const plainText = isAnchorTag || isImgTag ? Parser.htmlToMarkdown(content) : Parser.htmlToText(content);

We can do the same for video and other HTML tags too.

What alternative solutions did you explore? (Optional)