BioDrop icon indicating copy to clipboard operation
BioDrop copied to clipboard

[BUG] Copy to clipboard in the Share to social media icons is not working

Open nirbhay12345 opened this issue 4 years ago • 18 comments

Description

The following button is not working in the share to social media

  • copy to clip board

I tried clicking the button few times and it does not seem to copy the contents of the link. Instead it selects the contents of the description in the profile.

I am using BRAVE BROWSER.

At the time of this issue the linkfree is at the v0.58.3

Screenshots

ezgif-3-9210861ce8

Additional information

No response

nirbhay12345 avatar Jan 09 '22 12:01 nirbhay12345

It's great having you contribute to this project

Welcome to the community :nerd_face:

If you would like to continue contributing to open source and would like to do it with an awesome inclusive community, you should join our Discord chat and our GitHub Organisation - we help and encourage each other to contribute to open source little and often 🤓 . Any questions let us know.

github-actions[bot] avatar Jan 09 '22 12:01 github-actions[bot]

Hey Nirbhay , I want to work on this issue would you please assign me.

Abhi-paul16 avatar Jan 09 '22 14:01 Abhi-paul16

thanks for catching this issue. I just checked and a similar thing is happening in Chrome and it's throwing a console error. Screenshot 2022-01-09 155551

EmmaDawsonDev avatar Jan 09 '22 14:01 EmmaDawsonDev

@emmalearnscode can you help me in this all things working fine in development server.

Abhi-paul16 avatar Jan 09 '22 17:01 Abhi-paul16

https://user-images.githubusercontent.com/68468264/148693853-b6a684f3-a212-4d94-a5ab-6a7f9ef5470c.mp4

Abhi-paul16 avatar Jan 09 '22 17:01 Abhi-paul16

This is going to be hard to test as it's working in development but the copy to clipboard function is async and returns a promise so I wonder if the toast should be chained inside a .then block (see the examples here: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText )

EmmaDawsonDev avatar Jan 09 '22 18:01 EmmaDawsonDev

Hmm, I also found some information that this web API only works on https and we are currently using http so that may also be causing an issue

EmmaDawsonDev avatar Jan 09 '22 18:01 EmmaDawsonDev

@emmalearnscode Thanks for sharing it and helping.

Abhi-paul16 avatar Jan 09 '22 19:01 Abhi-paul16

@eddiejaoude we have a bug in the copy to clipboard on production being caused because the site is hosted on http instead of https and the api doesn't work on http. Is upgrading to https something you are planning to do with the project?

Maybe we should comment out the copy to clipboard icon/functionality if this is not something that can be resolved at this time? Or do you have another suggestion?

EmmaDawsonDev avatar Jan 13 '22 16:01 EmmaDawsonDev

@eddiejaoude we have a bug in the copy to clipboard on production being caused because the site is hosted on http instead of https and the api doesn't work on http. Is upgrading to https something you are planning to do with the project?

Maybe we should comment out the copy to clipboard icon/functionality if this is not something that can be resolved at this time? Or do you have another suggestion?

Upgrading to https sounds like a good idea to me. If that were to happen, every link in the code (if there is any). Should be with https instead of http.

DevCassie avatar Jan 13 '22 16:01 DevCassie

Thanks @emmalearnscode 👍 yes we plan to move to https, but i need some help with the Kubernetes config/setup - let me reach out to some people as i would like to do this on a live stream

Might be best to comment out for now

eddiejaoude avatar Jan 14 '22 01:01 eddiejaoude

Description

When the copy to clipboard button is clicked it throws the error navigator.clipboard is undefined. I am using Firefox v95.0.2 browser. I did some research, I found that navigator.clipboard is only available when the site you're browsing has a secure origin (HTTPS). http://linkfree.eddiehub.org/ is using (HTTP). I think because of that copy to clipboard is not working.

Screenshots

Error Screenshot

Additional information

My suggestion is to use old-school copy to clipboard using the out of viewport hidden textarea trick.

const CopyLink = () => {
  if (typeof(navigator.clipboard) == 'undefined') {
    // Do the out of viewport hidden textarea trick.
  }
  navigator.clipboard.writeText(`http://linkfree.eddiehub.org/${username}`)
  toast.current.show({
    severity: 'success',
    summary: 'Link copied to clipboard.',
  })
}

vikasganiga05 avatar Jan 14 '22 07:01 vikasganiga05

My suggestion is to use old-school copy to clipboard using the out of viewport hidden textarea trick.

I think for the time being this could be a helpful solution. Since it prevents the broken site.

Further this bug can be removed as mentioned by @eddiejaoude

What are others views? @emmalearnscode

nirbhay12345 avatar Jan 14 '22 08:01 nirbhay12345

My concern with adding the workaround is that it's not acutally possible to test it in development as the copy to clipboard is working on localhost. Therefore, we won't know if it works until pushing to production. Then when we finally do upgrade to https, there will be unnecessary code which we might forget to remove. My feeling would be to comment out the sharing link and just leave the three working social sharing links visible for now until Eddie has time to upgrade. Curious to see what others think.

EmmaDawsonDev avatar Jan 14 '22 10:01 EmmaDawsonDev

Therefore, we won't know if it works until pushing to production. Then when we finally do upgrade to https, there will be unnecessary code which we might forget to remove

Yeah I did not thought of this. This might turn out to be an overhead later. I agree that it should be commented.

nirbhay12345 avatar Jan 15 '22 04:01 nirbhay12345

For now, till this issue gets resolved, maybe remove the copy to clipboard icon?

KendallDoesCoding avatar Feb 10 '22 18:02 KendallDoesCoding

This can be done using JS: https://stackoverflow.com/questions/49618618/copy-current-url-to-clipboard

KendallDoesCoding avatar Feb 10 '22 18:02 KendallDoesCoding

https has now been added to the LinkFree project and I just tested the copy link and it works 🎉

Thank you all for the great collaboration 🔥

eddiejaoude avatar May 24 '22 12:05 eddiejaoude