Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobile view address copy issue #277

Open
jusasiiv opened this issue Jul 3, 2022 · 3 comments
Open

Mobile view address copy issue #277

jusasiiv opened this issue Jul 3, 2022 · 3 comments

Comments

@jusasiiv
Copy link
Collaborator

jusasiiv commented Jul 3, 2022

Merchant reported that when in mobile view, clicking copy the address gets two blank spaces appended to the end of the clipboard causing issues pasting to wallets.

@thisisayush
Copy link
Contributor

@DarrenWestwood

We can solve the issue by:

  1. Either replacing the document.execCommand('copy') (which is now depreciated) with the new Clipboard API of JS (94% Global Users support as per caniuse), and use that instead, as it doesn't rely on creating a temporary element to copy text.
  2. Setting the selectionRange selector.setSelectionRange(0, 99999);, as suggested at various sources for Mobile.

The suggested fix is that we can use the new Clipboard API along with a fallback to the older document.execCommand to support all cases.

@DarrenWestwood
Copy link
Collaborator

Please ensure you are able to replicate the issue in order to verify using Clipboard API correctly solves the issue. It looks like the issue is with selection rather than copying. Using selectionEnd or trim() appears to be recommended fix for this: https://stackoverflow.com/questions/34477425/javascript-execcommandcopy-copies-text-but-adds-extra-white-space-to-value

The suggested fix is that we can use the new Clipboard API along with a fallback to the older document.execCommand to support all cases.

Lets use Clipboard API, without fallback as this appears supported by most modern browsers.

@thisisayush
Copy link
Contributor

Alright, let's move to Clipboard API. P.S. I was not able to replicate the issue on my mobile device, I tried it with Edge Mobile Browser and Chrome Mobile Browser. Both of them seemed to copy the text without any spaces.

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

No branches or pull requests

3 participants