🐛 Bugfix: Fix inability to copy content to clipboard in http#3292
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes clipboard copy behavior in contexts where the modern Clipboard API is unavailable or blocked (e.g., non-secure HTTP origins) by switching the access-key copy action to a shared clipboard utility with a fallback mechanism.
Changes:
- Replaced direct
navigator.clipboard.writeText(...)usage withcopyToClipboard(...)for copying the access key. - Added the
copyToClipboardimport to the user profile component.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
🔍 Code Review Comments1. [代码规范] 2. [逻辑漏洞] 全局搜索遗漏 |
YehongPan
left a comment
There was a problem hiding this comment.
Code Review
- [代码规范]
copyToClipboard引入自@/lib/clipboard,应确认该模块是否已有 fallback 到document.execCommand('copy')的实现,纯navigator.clipboard在非 HTTPS 环境下会抛异常。 - [逻辑漏洞] 仅替换了
UserProfileComp.tsx中的一处调用,但项目中可能还有其他直接使用navigator.clipboard.writeText的地方未修复,应全局搜索确认。
|
LGTM. Simple fix — replacing innerText with innerHTML in the copy handler is appropriate. No issues found. |
No description provided.