Rocket.Chat.Electron
Rocket.Chat.Electron copied to clipboard
fix: File not getting download when clicked on its name
Closes RocketChat/Rocket.Chat.Electron#2763, RocketChat/Rocket.Chat.Electron#2764, RocketChat/Rocket.Chat.Electron#2723, RocketChat/Rocket.Chat.Electron#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:
- Working element (cloud icon)
- Problematic element (file name)
The difference is in the attributes of href
and download
. The working element
- Has the download attribute specifying the file name which is missing in the other.
- Has the
?download
applied at the end of the file's URL in thehref
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:
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?
Thanks @jeanfbrito for your views! I'll test it out on the latest versions of the servers and update you shortly.
@jeanfbrito I have tested it on the latest development version of the rocket chat server. It's still there.
Its only fixed (3.9.14) for pdf files but not for example docx etc pp