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

Fix copy with formatting for IE #93

Merged
merged 1 commit into from
Feb 3, 2020
Merged

Conversation

wdlb
Copy link
Contributor

@wdlb wdlb commented Jan 31, 2020

Hi! When using react-copy-to-clipboard, which is using this copy-to-clipboard module, I've encountered an issue in IE11.

In the function that was attached to the "copy" event using the mark.addEventListener("copy", function(e) { ... }) an error is thrown in IE11 due to the e.clipboardData being undefined. There's a try/catch present, but we do not end up in the catch block due to the fact that the error is thrown inside of the callback attached to the "copy" event and not inside of the root level function copy(text, options) { ... }.

I fixed this by checking explicitly if the e.clipboardData is undefined, and using the window.clipboardData if this is the case. I had to add some conversion of options as well, as per: https://msdn.microsoft.com/en-us/ie/ms536744(v=vs.94).

Could you have a look at this please? Thanks a lot!

@wdlb
Copy link
Contributor Author

wdlb commented Jan 31, 2020

This PR should solve this issue as well: #84

@sudodoki
Copy link
Owner

At glance, looks good. Let me get back to this when I get time to do the release as well

@sudodoki
Copy link
Owner

And thanks 🙏

@wdlb
Copy link
Contributor Author

wdlb commented Jan 31, 2020

You're welcome, thank you for all the time you have invested in this library! I've seen that the travis-ci build failed, should I do something about it? Because it's not entirely clear to me why exactly. Have a nice day!

@sudodoki
Copy link
Owner

sudodoki commented Feb 3, 2020

@wdlb no, you are good, it originally failed due to some inconsistencies between browsers, and I guess now it's because saucelab account expired or something like that.

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

Successfully merging this pull request may close these issues.

2 participants