romm icon indicating copy to clipboard operation
romm copied to clipboard

[Bug] Copy download link doesn't work

Open IvanMazzoli opened this issue 10 months ago • 6 comments

RomM version RomM 3.1.0-rc.3

Describe the bug When clicking the copy download link button, nothing happens.

To Reproduce Steps to reproduce the behavior:

  1. Go to any game in your library
  2. Click on the copy button
  3. Try to paste (eg. in a txt file)
  4. Nothing has been copied

Expected behavior When clicking the copy button, the download link should be copied to the clipboard. Even better, a small toast with "Download link copied to the clipboard" should be displayed to the user.

Screenshots image

Desktop:

  • OS: Windows 10
  • Browser: Google Chrome
  • Version: 124.0.6367.60 (Official build) (64 bit) (cohort: M124 Rollout)

Additional context Also tried with Microsoft Edge, can reproduce the issue. Tried with single file ROMs games (eg. NES) and multi file ROMs (eg. PS1) and both produces the same issue.

IvanMazzoli avatar Apr 18 '24 14:04 IvanMazzoli

To be honest I only tested it in Firefox. Could you test with firefox and post the results? About the toast it will appear when you copy the link, but didn't add any if the copy somehow fail! I'll add it for the final 3.1 release

I'll test myself in chrome and edge of course

zurdi15 avatar Apr 18 '24 16:04 zurdi15

I had to switch PC, now I'm on Windows 11 and with Firefox (fresh installation) I still can't copy the download link. Here's the console error message: image

EDIT: surfing StackOverflow I might have found what's causing the issue: https://stackoverflow.com/questions/51805395/navigator-clipboard-is-undefined In fact I'm not using HTTPS and Romm is in a different machine than the one I'm using the browser on. I tried to change the flag in Chrome as suggested in Simon Dehaut's answer but it still doesn't work. Do you think it's possible to try the "hack" he suggested on SO?

IvanMazzoli avatar Apr 18 '24 17:04 IvanMazzoli

lmaooooo i can't believe i didn't see this in the PR 🤦🏼 navigator.clipboard is only available in secure contexts (https pages), and looking at your screenshots you're accessing it via an ip address.

@zurdi15 you used to be able to use document.execCommand as a workaround, but that was deprecated years ago and browsers are finally starting to remove it. i think the best thing is to just hide the button if the context isn't secure (not https web page)

gantoine avatar Apr 18 '24 21:04 gantoine

I don't really like the idea of not being able to just share the link if my connection isn't secure... what about a different approach like Google Photos? image If a secure context isn't available, just grey out the copy button but allow the user to copy it manually. In this case a better icon for the copy button would be a share one, like share-variant.

IvanMazzoli avatar Apr 19 '24 06:04 IvanMazzoli

lmaooooo i can't believe i didn't see this in the PR 🤦🏼 navigator.clipboard is only available in secure contexts (https pages), and looking at your screenshots you're accessing it via an ip address.

wow how is this possible? how could I use navigator.clipboard then? is it because localhost is taken as secure context?

In any case I like the google photos approach, if that method is not available we show a popup with the link to copy it manually

zurdi15 avatar Apr 19 '24 07:04 zurdi15

is it because localhost is taken as secure context?

yes something like that!

if that method is not available we show a popup with the link to copy it manually

makes sense to me, assigning this to you and backlogging it

gantoine avatar Apr 19 '24 13:04 gantoine

This will be available in the next release (3.2.0).

gantoine avatar May 27 '24 03:05 gantoine