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

Does not copy empty string to clipboard #85

Open
gitname opened this issue Dec 17, 2017 · 1 comment
Open

Does not copy empty string to clipboard #85

gitname opened this issue Dec 17, 2017 · 1 comment

Comments

@gitname
Copy link

gitname commented Dec 17, 2017

When value of the text prop is an empty string (i.e. ""), the result parameter inside onCopy is true, but the empty string is not copied to the clipboard. Instead, the clipboard retains whatever was already on it.

Demo: https://codepen.io/anon/pen/VyvgOr

  • This demo is a fork of the demo linked in README.md. The only difference is that state.value has been initialized to an empty string (i.e. "") instead of to "some\ntext". To reproduce the issue, you can manually pre-load your clipboard with a non-empty string (e.g. "abc") and then click on the "Copy to clipboard with button" button in the demo. Although the demo will show the red "Copied" message (suggesting, to me, that the empty string has been copied to the clipboard), the clipboard will continue to contain the previous string (e.g. "abc") instead of the empty string.

I expected the clipboard to contain the empty string (i.e. I expected the clipboard to be empty).

Observed in:

  • Chrome Version 62.0.3202.94 (Official Build) (64-bit) running on Windows 7 64-bit
@nkbt
Copy link
Owner

nkbt commented Dec 17, 2017

There is no explicit checks in react-copy-to-clipboard an copy-to-clipboard (that it uses), feels like it may be a default browser behaviour =(

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

2 participants