Add affiliate dashboard copy fallback - #154
Conversation
Greptile SummaryThis PR hardens the affiliate dashboard copy flow by introducing a
Confidence Score: 3/5Safe to merge once the missing The src/app/dashboard/affiliates/DashboardClient.tsx — specifically the Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[User clicks CopyButton] --> B{stopPropagation?}
B -- Yes --> C[e.preventDefault + e.stopPropagation]
B -- No --> D[await copyText]
C --> D
D --> E{navigator.clipboard available?}
E -- Yes --> F[clipboard.writeText]
F -- Success --> G[return true]
F -- Throws --> H[catch: fall through]
H --> I[textarea fallback]
E -- No --> I
I --> J[document.body.appendChild textarea]
J --> K[textarea.select]
K --> L[execCommand copy]
L -- Success --> M[finally: removeChild]
L -- Throws SecurityError --> N[⚠️ unhandled exception propagates]
M --> O{result true?}
N --> P[Unhandled promise rejection]
O -- Yes --> Q[setCopied true, timeout 2s]
O -- No --> R[No UI feedback]
Reviews (1): Last reviewed commit: "Add affiliate dashboard copy fallback" | Re-trigger Greptile |
| try { | ||
| return document.execCommand("copy"); | ||
| } finally { | ||
| document.body.removeChild(textarea); | ||
| } | ||
| } |
There was a problem hiding this comment.
Unhandled exception in textarea fallback path
The inner try/finally for execCommand has no catch. document.execCommand('copy') can throw a SecurityError or InvalidStateError (e.g., in a cross-origin iframe, or when no text is selected). If it does, the exception propagates out of copyText as a rejected Promise, and the async onClick handler has no catch either — producing a silent unhandled promise rejection and leaving the UI without feedback.
| try { | |
| return document.execCommand("copy"); | |
| } finally { | |
| document.body.removeChild(textarea); | |
| } | |
| } | |
| try { | |
| return document.execCommand("copy"); | |
| } catch { | |
| return false; | |
| } finally { | |
| document.body.removeChild(textarea); | |
| } | |
| } |
Summary
Closes #153.
This is for the active uGig affiliate/invite testing task: 4741218f-a723-46bb-82cb-6516120331ae.
Payment address for the uGig SOL bounty, if accepted:
27sdMYXofqoM9qR13bZhccRNYeEgYn5EoHXTSJn4QWKPValidation
pnpm exec eslint src/app/dashboard/affiliates/DashboardClient.tsxpnpm type-checkgit diff --check -- src/app/dashboard/affiliates/DashboardClient.tsxPayment fallback: PayPal cultofrozen@gmail.com