Context
js/copy-code.js sets the label to "Copied" and schedules a setTimeout to put it back after 1600ms. Clicking again before that fires schedules a second timer while the first is still pending, so the label reverts early and can flicker between states.
What to change
Files: js/copy-code.js
Requirements:
- Keep a reference to the pending timer and clear it before starting a new one
- Rapid clicks should mean the label stays "Copied" for the full period after the last click
- Per button — one block's timer must not affect another's
- Do not introduce a global; the existing code is an IIFE per block for a reason
Acceptance criteria
How to verify locally
Open any page with code blocks and click one Copy button five times in a second.
python3 -m http.server 8000
Then open http://localhost:8000.
Difficulty
Intermediate. A small, satisfying bug with a clear reproduction.
New here? Comment /claim on this issue and a bot will assign it to you. Then read CONTRIBUTING.md.
Stuck at any point? Comment here saying what you have tried and where it stopped working — that is not an admission of failure, it is how we find out the instructions were unclear. You can also come to a PR Debug Clinic (Oct 12 or Oct 21).
Context
js/copy-code.jssets the label to "Copied" and schedules asetTimeoutto put it back after 1600ms. Clicking again before that fires schedules a second timer while the first is still pending, so the label reverts early and can flicker between states.What to change
Files:
js/copy-code.jsRequirements:
Acceptance criteria
How to verify locally
Open any page with code blocks and click one Copy button five times in a second.
Then open http://localhost:8000.
Difficulty
Intermediate. A small, satisfying bug with a clear reproduction.
New here? Comment
/claimon this issue and a bot will assign it to you. Then read CONTRIBUTING.md.Stuck at any point? Comment here saying what you have tried and where it stopped working — that is not an admission of failure, it is how we find out the instructions were unclear. You can also come to a PR Debug Clinic (Oct 12 or Oct 21).