Commit 018763e
authored
fix(frontend): wait for clipboard write before showing copied state (JhaSourav07#2259)
## Description
Fixes JhaSourav07#2255
## Pillar
- [x] 🛠️ Other (Bug fix, refactoring, docs)
## What changed
The landing page copy handler was marking the badge markdown as copied
immediately after calling `navigator.clipboard.writeText`. Since
`writeText` returns a Promise, a rejected clipboard write could still
show the `Copied` state and open the success guide.
This PR makes the handler wait for the clipboard write to finish before
updating the UI. If the browser rejects the write, the page leaves the
copy state unset instead of showing a false success.
I also added a regression test that mocks
`navigator.clipboard.writeText` to reject and verifies the success UI is
not shown.
## Visual Preview
N/A - this is a copy-state behavior fix.
## Local verification
- `npm run test -- app/page.test.tsx` passed
- `npm run test -- app/customize/components/ThemeQuickPresets.test.tsx`
passed after that test timed out once during the full suite run
- `npm run format:check` passed
- `npm run lint` passed with existing warnings only
- `npm run typecheck` passed
## GSSoC 2026
This issue and PR are raised under GSSoC 2026. Please add the relevant
GSSoC/level labels if they do not sync from the issue automatically.
## Checklist before requesting a review:
- [x] I have read the `CONTRIBUTING.md` file.
- [x] I have tested these changes locally
(`localhost:3000/api/streak?user=YOUR_USERNAME`).
- [x] I have run `npm run format` / `npm run format:check` and `npm run
lint` locally.
- [x] My commits follow the Conventional Commits format.
- [x] I have updated `README.md` if I added a new theme or URL
parameter.
- [x] I have starred the repo.
- [x] I have made sure that I have only one commit to merge in this PR.
- [x] The SVG output matches the CommitPulse quality standard.2 files changed
Lines changed: 28 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
277 | 297 | | |
278 | 298 | | |
279 | 299 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
| 107 | + | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
110 | 117 | | |
111 | 118 | | |
112 | | - | |
113 | | - | |
114 | 119 | | |
115 | 120 | | |
116 | 121 | | |
| |||
0 commit comments