Refactor Clipboard Utility: Unified Copy Function with Fallback Support#8187
Refactor Clipboard Utility: Unified Copy Function with Fallback Support#8187kanishka-2007-tech wants to merge 2 commits into
Conversation
|
@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. |
|
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! |
|
🚨 Hey @kanishka-2007-tech, the CI Pipeline is failing on this PR and it has been marked as 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 passes2. Auto-fix common issues: npm run format # Auto-fix formatting with Prettier
npm run lint -- --fix # Auto-fix lint errors where possible3. Check the full failure log here: Once you push a fix and the CI passes, the |
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 anddocument.execCommand('copy')on older browsers or non-secure contexts.Changes Made
utils/clipboard.ts:copyToClipboard(text: string): Promise<void>.navigator.clipboard.writeTextand transparently handles failures by invokingfallbackCopyToClipboard(which uses the deprecateddocument.execCommand).Fixes #3694
Pillar
Checklist before requesting a review:
CONTRIBUTING.mdfile.localhost:3000/api/streak?user=YOUR_USERNAME).npm run formatandnpm run lintlocally and resolved all errors (CI will fail otherwise).feat(themes): ...,fix(calculate): ...).README.mdif I added a new theme or URL parameter.