Skip to content

fix(ui): make readme markdown copy work in safari#2182

Open
MathurAditya724 wants to merge 4 commits intonpmx-dev:mainfrom
MathurAditya724:patch-1
Open

fix(ui): make readme markdown copy work in safari#2182
MathurAditya724 wants to merge 4 commits intonpmx-dev:mainfrom
MathurAditya724:patch-1

Conversation

@MathurAditya724
Copy link
Copy Markdown
Contributor

🔗 Linked issue

Fixes #2151

🧭 Context

The "Copy as Markdown" button in the README section wasn’t working in Safari.
It could fail silently because we were waiting for an async fetch before writing to clipboard.

📚 Description

This PR makes the README copy flow more reliable in Safari:

  • enabled VueUse clipboard legacy mode so it can fall back to execCommand('copy') when needed
  • reuse already-fetched markdown if it exists
  • only fetch markdown on click when it’s missing

Result: "Copy as Markdown" now works consistently, including Safari.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs.npmx.dev Ready Ready Preview, Comment Mar 29, 2026 2:01pm
npmx.dev Ready Ready Preview, Comment Mar 29, 2026 2:01pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
npmx-lunaria Ignored Ignored Mar 29, 2026 2:01pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b303605c-a39c-4e12-9f0a-0e4547859eb8

📥 Commits

Reviewing files that changed from the base of the PR and between a39742e and 063c427.

📒 Files selected for processing (1)
  • app/pages/package/[[org]]/[name].vue
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/pages/package/[[org]]/[name].vue

📝 Walkthrough

Walkthrough

Adds a client-only conditional prefetch helper maybePrefetchReadmeMarkdown that watches readmeData.value.mdExists and readmeMarkdownStatus (with immediate: true) and calls fetchReadmeMarkdown() when appropriate. prefetchReadmeMarkdown() now delegates to this helper. Introduces isCopyingReadme to prevent re-entrancy in the README copy flow; copyReadmeHandler() fetches markdown only if missing, sets the flag during operation, and resets it in finally. README copy button bindings (tooltip, aria-label, icon, text, disabled, aria-busy) were updated to reflect loading/copy states.

Possibly related PRs

Suggested reviewers

  • ghostdevv
  • trueberryless
  • danielroe
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The PR description clearly relates to the changeset, explaining the Safari compatibility issue and the specific modifications made to fix the clipboard copy functionality.
Linked Issues check ✅ Passed The PR successfully addresses issue #2151 by implementing all required objectives: enabling clipboard legacy mode fallback, reusing prefetched markdown, and only fetching when missing. The changes ensure reliable clipboard writes within user gestures.
Out of Scope Changes check ✅ Passed All changes in the single modified file focus exclusively on fixing the README markdown copy functionality in Safari, directly addressing the linked issue requirements without introducing unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 21, 2026

Codecov Report

❌ Patch coverage is 0% with 22 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
app/pages/package/[[org]]/[name].vue 0.00% 15 Missing and 7 partials ⚠️

📢 Thoughts on this report? Let us know!

@ghostdevv ghostdevv self-requested a review March 21, 2026 20:54
@MathurAditya724
Copy link
Copy Markdown
Contributor Author

I re-tested this on WebKit/Safari with the latest changes and it now works reliably, including the first click after navigation. I added a loading state + markdown prefetch, and kept the clipboard legacy fallback. Here’s a quick demo -

Screen.Recording.2026-03-22.at.12.34.08.PM.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants