Skip to content

fix(ui): reset the CopyButton checkmark after each copy#1282

Open
abhay-codes07 wants to merge 1 commit into
supermemoryai:mainfrom
abhay-codes07:fix/ui-copy-button-reset
Open

fix(ui): reset the CopyButton checkmark after each copy#1282
abhay-codes07 wants to merge 1 commit into
supermemoryai:mainfrom
abhay-codes07:fix/ui-copy-button-reset

Conversation

@abhay-codes07

Copy link
Copy Markdown
Contributor

What

The CopyButton checkmark 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 sets hasCopied back to false after a copy:

useEffect(() => {
    setTimeout(() => { setHasCopied(false) }, 2000)
}, [])

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 hasCopied with proper cleanup — the same pattern the sibling copyable-cell.tsx already uses:

useEffect(() => {
    if (!hasCopied) return
    const timer = setTimeout(() => setHasCopied(false), 2000)
    return () => clearTimeout(timer)
}, [hasCopied])

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 build in apps/web (the consumer) — clean
  • biome check on the touched file — clean

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.
Copilot AI review requested due to automatic review settings July 13, 2026 05:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants