Skip to content

Refactor Clipboard Utility: Unified Copy Function with Fallback Support#8187

Open
kanishka-2007-tech wants to merge 2 commits into
JhaSourav07:mainfrom
kanishka-2007-tech:exe
Open

Refactor Clipboard Utility: Unified Copy Function with Fallback Support#8187
kanishka-2007-tech wants to merge 2 commits into
JhaSourav07:mainfrom
kanishka-2007-tech:exe

Conversation

@kanishka-2007-tech

@kanishka-2007-tech kanishka-2007-tech commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Description

This PR transitions all clipboard copy operations across the application to a unified, resilient utility. It ensures that the modern navigator.clipboard.writeText() API is used as the primary copy mechanism everywhere, while seamlessly falling back to a text-area selection and document.execCommand('copy') on older browsers or non-secure contexts.

Changes Made

  • utils/clipboard.ts:
    • Exported a new utility function copyToClipboard(text: string): Promise<void>.
    • Prioritizes navigator.clipboard.writeText and transparently handles failures by invoking fallbackCopyToClipboard (which uses the deprecated document.execCommand).
    • Throws an error only if both the primary and fallback mechanisms fail.

Fixes #3694

Pillar

  • 🎨 Pillar 1 — New Theme Design
  • 📐 Pillar 2 — Geometric SVG Improvement
  • 🕐 Pillar 3 — Timezone Logic Optimization
  • 🛠️ Other (Bug fix, refactoring, docs)

Checklist before requesting a review:

  • I have read the CONTRIBUTING.md file.
  • I have tested these changes locally (localhost:3000/api/streak?user=YOUR_USERNAME).
  • I have run npm run format and npm run lint locally and resolved all errors (CI will fail otherwise).
  • My commits follow the Conventional Commits format (e.g., feat(themes): ..., fix(calculate): ...).
  • I have updated README.md if I added a new theme or URL parameter.
  • I have started the repo.
  • I have made sure that i have only one commit to merge in this PR.
  • The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts).
  • (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.

@vercel

vercel Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

@kanishka-2007-tech is attempting to deploy a commit to the jhasourav07's projects Team on Vercel.

A member of the Team first needs to authorize it.

@retenta-bot

retenta-bot Bot commented Jul 19, 2026

Copy link
Copy Markdown

This PR introduces a new utility for clipboard operations, enhancing the application's resilience and compatibility across different browsers. It aligns with previous decisions to modernize clipboard handling, such as replacing deprecated methods with the Clipboard API in other components. This change should improve the overall user experience while maintaining support for legacy environments. Thank you for your contribution!

@retenta-bot retenta-bot Bot changed the title refactor(clipboard): implement unified copyToClipboard utility with fallback support repo-wide Refactor Clipboard Utility: Unified Copy Function with Fallback Support Jul 19, 2026
@github-actions github-actions Bot added the status:blocked This PR is blocked due to a failing CI check. label Jul 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚨 Hey @kanishka-2007-tech, the CI Pipeline is failing on this PR and it has been marked as status:blocked.

Please fix the issues before this can be reviewed. Here's how:

1. Run checks locally before pushing:

npm run format:check   # Check Prettier formatting
npm run lint           # Run ESLint
npm run typecheck      # TypeScript type check
npm run test           # Run unit tests (Vitest)
npm run build          # Verify production build passes

2. Auto-fix common issues:

npm run format         # Auto-fix formatting with Prettier
npm run lint -- --fix  # Auto-fix lint errors where possible

3. Check the full failure log here:
👉 View CI Run

Once you push a fix and the CI passes, the status:blocked label will be removed automatically. 💪

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

Labels

status:blocked This PR is blocked due to a failing CI check.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace deprecated document.execCommand('copy') in ShareSheet

1 participant