fix: guard clipboard copy actions#2292
Conversation
|
@AjTheSpidey is attempting to deploy a commit to the HyperDX Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: 345161c The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
PR Review✅ No critical issues found. Solid, well-scoped fix for #2135. A few minor observations (non-blocking):
|
Deep Review✅ No critical issues found. 🟡 P2 — recommended
🔵 P3 nitpicks (10)
Reviewers (5): correctness, testing, maintainability, julik-frontend-races, kieran-typescript. Testing gaps:
|
d7405ce to
87f079b
Compare
|
Pushed an update after rebasing on latest main. I changed the clipboard helper so it only uses the textarea fallback when the Clipboard API is missing. If navigator.clipboard.writeText exists but rejects, it now returns false instead of trying the fallback after the async rejection. I also added coverage for that case and for execCommand throwing while making sure the temporary textarea is removed. Checked locally:
|
|
Pushed another small follow-up for the deep-review notes. This now tries the textarea fallback if navigator.clipboard.writeText rejects, moves the util test into src/utils/tests, adds coverage for selection restore / cleanup, keeps the row JSON copy path guarded, and updates the changeset quote style. Checked locally:
|
Summary
Fixes #2135.
Adds a shared
copyTextToClipboardhelper for the trace/event copy actions. It now:navigator.clipboard.writeTextwhen the browser permits itdocument.execCommand('copy')path when the Clipboard API is unavailable, such as insecure/non-HTTPS contextsCannot read properties of undefined (reading 'writeText')Screenshots or video
No screenshot included. This changes the failure/fallback path for browser clipboard permissions rather than the normal visible layout.
How to test on Vercel preview
Preview routes: /search
Steps:
Could not access the clipboard. Check browser permissions or use HTTPS.if clipboard access is unavailable.References
Validation
yarn build:common-utilsyarn workspace @hyperdx/app jest --runTestsByPath src/utils/clipboard.test.ts src/components/DBRowJsonViewer.test.tsx --coverage=false(passes; existing Mantine notificationact(...)warnings are printed)yarn workspace @hyperdx/app exec tsc --noEmityarn workspace @hyperdx/app exec npx eslint --quiet src/utils/clipboard.ts src/utils/clipboard.test.ts src/components/DBRowJsonViewer.tsx src/components/DBTable/DBRowTableFieldWithPopover.tsx src/components/DBTable/DBRowTableRowButtons.tsxNote: full
yarn workspace @hyperdx/app lintis blocked locally on Windows by unrelated CRLF Prettier errors across existing files in the checkout.