Conversation
The writeText() API works in Chrome, Edge, and Firefox but fails in Safari due to stricter user gesture requirements. Safari rejects clipboard writes when async operations (fetch) occur before the write. Switch to ClipboardItem API which reserves clipboard permission at click time while content loads asynchronously. This approach works across all modern browsers including Safari.
|
👋 Hello @fcakyon, thank you for submitting a -✅ Define a Purpose: Clearly explain the purpose of your fix or feature in your PR description, and link to any relevant issues. Ensure your commit messages are clear, concise, and adhere to the project's conventions. For more guidance, please refer to our Contributing Guide. Don't hesitate to leave a comment if you have any questions. Thank you for contributing to Ultralytics! 🚀 |
UltralyticsAssistant
left a comment
There was a problem hiding this comment.
🔍 PR Review
Made with ❤️ by Ultralytics Actions
Looks clean—no issues found based on the diff. The refactor to async content generation and ClipboardItem usage appears safe and consistent with existing behavior.
Summary
fetch) occur before the clipboard writenavigator.clipboard.writeText()toClipboardItemAPI which reserves clipboard permission at click time while content loads asynchronouslyTest
Tested on Safari 18 - button now shows "Copied!" and markdown content is correctly copied to clipboard.
🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Fixes Safari clipboard copy failures by switching to
ClipboardItem-based async content generation. 🧩📊 Key Changes
getContent()helpernavigator.clipboard.writeText(...)withnavigator.clipboard.write([new ClipboardItem(...)])🎯 Purpose & Impact