Skip to content

"Copy as Markdown" button on README doesn't copy to clipboard in Safari #2151

@mutewinter

Description

@mutewinter

Describe the bug

The "Copy as Markdown" button in the README section header silently fails and nothing is copied to the clipboard. Confirmed in Safari.

Root cause:

copyReadmeHandler() does await fetchReadmeMarkdown() before calling useClipboard's copy(). Safari requires navigator.clipboard.writeText() to be called synchronously within a user gesture. The async fetch breaks that chain, so Safari silently rejects the write.

Code block copy buttons work fine because they call copy() synchronously in the click handler.

Steps to reproduce:

  1. Open any package page with a README (e.g. /package/vue)
  2. Click the "Copy as Markdown" button (markdown icon) in the README header
  3. Paste — nothing was copied

Expected: README markdown content is copied to the clipboard.

Suggested fix:

Fall back to document.execCommand('copy') via a hidden textarea when navigator.clipboard.writeText() fails after the async fetch.

I'm not a Vue expert, so I didn't want to just submit an agent-generated pull request for a framework I'm not super familiar with.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions