nkbt / react-copy-to-clipboard

Copy-to-clipboard React component

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Two clicks required to copy sometimes

mhuggins opened this issue · comments

This is an issue in copy-to-clipboard itself, which would be fixed if this PR is merged: sudodoki/copy-to-clipboard#63. Since copy-to-clipboard seems to be abandoned, is there a scenario where this repo might use a supported fork or anything along those lines?

Last response was

Would it be possible to add a maintainer to this repo to help get in some vital fixes like this one?

Sure, anyone who is willing could become one, should I add you?

So I reckon someone could totally do that

commented

please...may be...Why do I have to click twice to copy the address of the current click?

@nkbt any news about a possible fix ? Spasibo!

No updates from the original lib yet ¯_(ツ)_/¯... Not much we can do here

Yeah, the original lib owner (@sudodoki) would like a way to reproduce it, and I don't have a suggestion on how to do that. It happened for me in one case, but not another, and I didn't have time to invest to see why -- forking and fixing the lib was my route.

Well, @mhuggins... So if you did not have time to invest to see why some elusive problem exists, what makes you think lib maintainers have time to invest to do it?

I don't, but there's an open PR that fixes the issue that he won't pull in either. Many other users of the lib have commented on the PR stating that it fixes the issue.

@mhuggins it's not that I won't pull it, it just that removeAllRanges is already called as I mentioned in here so I don't get what is the case when you need to call it twice and asked for help digging to the bottom of this. There were some minor changes in recent version of upstream lib, and I wonder whether that might affect this issue in any way

any news about a possible fix ?

@sudodoki I see your point. I didn't get to dig into it at the time, but I do know that the change solved the problem for me. It was a very specific scenario where I encountered it, but other scenarios worked, so I'm not sure what the difference was.

"Solved" by adding:
document.getElementById('ID_OF_BUTTON').click();
to onCopy handler.
...

I also ran into this problem. This component uses function from pocket copy-to-clipboard, which takes the text as the first argument and copy it into the buffer.

Same. Any alternative packages to recommend?

export default (words) => { const textField = document.createElement("textarea"); textField.innerText = words; document.body.appendChild(textField); textField.select(); document.execCommand("copy"); };
Need to hide the textarea but it should work