clipboard.js
clipboard.js copied to clipboard
Doesn't work properly in Safari 16.5.1
For some reason I cannot explain, copying is not working properly in Safari 16.5.1, but is perfectly fine in Firefox. It doesn't look like there's something wrong with JavaScript execution in this browser, and I don't have any weird experimental features enabled. But Clipboard.js seems to empty clipboard instead of copying a string in Safari.
https://urbanpsychopaths.com ↑ See “Website Link” at the bottom right block
Apple changed their behaviour and permissions to write text into the clipboard (maybe it's a bug from Apple? Don't know). It only works as a blob because the clipboard needs a promise. You can write a fallback function for JS, like:
if (navigator.clipboard && navigator.clipboard.write) { var data = [new ClipboardItem({ "text/plain": Promise.resolve(new Blob(["Copy Text"], { type: 'text/plain' })) })]; navigator.clipboard.write(data).then(function () { //function }, function (e) { console.log(e); }); }
Hopefully this getting fixed soon.
我和你碰到了同样的问题,测试后删除一个css可以解决: -webkit-user-select:none;
我和你碰到了同样的问题,测试后删除一个css可以解决: -webkit-user-select:none;
Doesn't work for me. The text is still not in the clipboard.
我和你碰到了同样的问题,测试后删除一个css可以解决: -webkit-user-select:none;
I confirm that checking that the container of the text you are copying does not have this line fix the problem.
Hey @dentalala, I'm planning to contribute to some open issues. Can you confirm if your problem remains? For now, it seems not related to clipboard.js, so closing. If that's not the case, soon I will be triaging so we can investigate in deep, and potentially, find a fix. So feel free to reopen it if that's the case.