rommapp / romm

A beautiful, powerful, self-hosted rom manager
https://romm.app
GNU Affero General Public License v3.0
1.81k stars 81 forks source link

[Bug] Copy download link doesn't work #818

Closed IvanMazzoli closed 3 months ago

IvanMazzoli commented 5 months ago

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:

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.

zurdi15 commented 5 months ago

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

IvanMazzoli commented 5 months ago

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?

gantoine commented 5 months ago

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)

IvanMazzoli commented 5 months ago

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.

zurdi15 commented 5 months ago

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

gantoine commented 5 months ago

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 commented 3 months ago

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