Fix unreliable copy to clipboard in render-markdown#145
Conversation
The clipboard copy was failing in many scenarios because it only used
navigator.clipboard.writeText() without a fallback. This API can fail
when the page lacks focus, permissions are denied, or in certain browser
contexts.
Added a robust fallback approach:
1. Try navigator.clipboard.writeText() first (modern API)
2. Fall back to document.execCommand('copy') on textarea
3. As last resort, select text and prompt user to copy manually
Also simplified the success feedback by removing the floating message
animation in favor of a simpler button text/color change.
|
Claude finished @simonw's task —— View job Code Review for Clipboard Fix PR ✅Reviewing the clipboard copy implementation and fallback mechanisms. Todo List:
✅ Overall Assessment: Excellent ImplementationThis PR effectively addresses the unreliable clipboard functionality with a well-designed progressive fallback approach. The implementation follows best practices and significantly improves user experience. 🔒 Security ReviewNo security concerns identified:
🎯 Code Quality & Best PracticesExcellent practices observed:
Minor suggestions:
🚀 Performance ConsiderationsWell optimized:
⚡ Functional ImprovementsExcellent implementation choices:
📝 Test Coverage AssessmentCurrent implementation is self-testing through fallbacks, but consider:
🎉 Strengths
🔍 No Issues Found
✅ Recommendation: ApproveThis PR successfully resolves the clipboard reliability issues with a robust, well-implemented solution. The code quality is high, security is maintained, and user experience is significantly improved. |
The clipboard copy was failing in many scenarios because it only used
navigator.clipboard.writeText() without a fallback. This API can fail
when the page lacks focus, permissions are denied, or in certain browser
contexts.
Added a robust fallback approach:
Also simplified the success feedback by removing the floating message
animation in favor of a simpler button text/color change.