Skip to content

Conversation

preeesha
Copy link

@preeesha preeesha commented Dec 31, 2023

Closes #2763, #2764, #2723, #2615 (may be)

It was observed in the mentioned issue that the users of the desktop app (only) were not able to download the file when clicked on it's name. Though, it was possible by clicking on the little cloud icon. So, this was a discrepancy in the UX. During my investigation I have found that the issue lies in the Rocket.Chat's web view although it's behaviour is pretty suitable for the browser. But for desktop, we can fix it here.

It was observed that it's caused due to the difference in the link building or <a> tag in the rocket chat's web view. Here're the differences:

  1. Working element (cloud icon)
    image
  2. Problematic element (file name)
    image

The difference is in the attributes of href and download. The working element

  1. Has the download attribute specifying the file name which is missing in the other.
  2. Has the ?download applied at the end of the file's URL in the href attribute

To solve this issue, I have attached an event listener to the DOM of the Rocket.Chat's webview and whenever a link is clicked it checks whether the link is meant to download a file or not.
If it is, a new temporary element (<a>) is created in the DOM with the modified attributes to process the download of the file.

Here're the results:
Animation

@preeesha preeesha changed the title fix: File not getting download when clicked on its name (#2799) fix: File not getting download when clicked on its name Dec 31, 2023
@jeanfbrito
Copy link
Collaborator

This seems a little instrusive, the core team already modified the core to fix this. Dont think that we should make this to fix the issue. Can you test the newer version of server to see what happens?

@preeesha
Copy link
Author

preeesha commented Feb 6, 2024

Thanks @jeanfbrito for your views!
I'll test it out on the latest versions of the servers and update you shortly.

@preeesha
Copy link
Author

preeesha commented Feb 9, 2024

@jeanfbrito I have tested it on the latest development version of the rocket chat server. It's still there.

@teach404W
Copy link

Its only fixed (3.9.14) for pdf files but not for example docx etc pp

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.

Empty file attachments
3 participants