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

copyed in the second time in chrome #90

Open
wutw opened this issue Jan 1, 2020 · 3 comments
Open

copyed in the second time in chrome #90

wutw opened this issue Jan 1, 2020 · 3 comments

Comments

@wutw
Copy link

wutw commented Jan 1, 2020

copyed in the second time in chrome

@inlinecoder
Copy link

I believe, @wutw could have elaborated better on this matter. I'll try my best: using the copy method doesn't work, when you're initiating it for the first time. But, next time it works ok. I personally have tried async retries with variable sleep timers and it didn't help.

Doesn't work in Safari (13.1) and a Mobile Safari on iOS 13.1.

@Apindes
Copy link

Apindes commented Sep 8, 2021

I ve discovered that before calling selection.addRange(range); it is necessary to remove all ranges from the selection. So in index.js before addRange call you need to call removeAllRanges:

...
selection.removeAllRanges();
selection.addRange(range);

https://github.com/sudodoki/copy-to-clipboard/blob/master/index.js#L75

@sudodoki
Copy link
Owner

sudodoki commented Sep 8, 2021

It's weird, as removeAllRanges is done in https://github.com/sudodoki/toggle-selection/blob/gh-pages/index.js#L25 which is called before initiating copy logic

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

4 participants