fix(ui): reset the CopyButton checkmark after each copy#1282
fix(ui): reset the CopyButton checkmark after each copy#1282abhay-codes07 wants to merge 1 commit into
Conversation
The reset timer ran once on mount with an empty dependency array, so it fired two seconds after render, before any click, and nothing ever set hasCopied back to false afterwards. The first copy swapped the clipboard icon to a checkmark permanently and later copies gave no visual feedback. Key the effect on hasCopied with a cleanup, the same pattern copyable-cell.tsx already uses: every copy shows the checkmark for two seconds and reverts, rapid re-copies restart the window, and the stray mount-time timer is gone.
|
The changes are good but I could not reproduce this exact issue point, can you point me to the exact page where this file is being used? I think this file ( |
|
Good catch @ishaanxgupta, and you are right about The component fixed here is the shared one in The bug itself: the reset effect runs once on mount instead of after a copy. The 2 second timer starts when the component first renders, so it fires while If you would rather remove the component entirely since nothing imports it yet, I am happy to rework this PR into a deletion instead. Just let me know which way you want it. |
|
@ishaanxgupta here is the reproduction. Since nothing imports this shared component yet, there is no prod page to click, so I rendered the actual Left ( The reason it is easy to miss: the reset timer on
The harness clicks after the mount timer has elapsed, which is why |

What
The
CopyButtoncheckmark never resets. The reset timer runs once on mount with an empty dependency array — i.e. it fires (uselessly) two seconds after render, before any click — and nothing ever setshasCopiedback tofalseafter a copy:In the integrations install-steps (the component's consumer), the first copy click swaps the clipboard icon to a checkmark permanently; subsequent copies give no visual feedback at all.
Fix
Key the effect on
hasCopiedwith proper cleanup — the same pattern the siblingcopyable-cell.tsxalready uses:Each copy now shows the checkmark for 2 seconds and reverts; rapid re-copies restart the window cleanly, and the stray mount-time timer is gone.
Testing
bun run buildinapps/web(the consumer) — cleanbiome checkon the touched file — clean