Skip to content

CopyButton never resets its checkmark after copying #1761

Description

@puang59

Description

CopyButton swaps to a check icon after a click, but the check never reverts to the clipboard icon reliably. The 2s reset timer is started in a useEffect with an empty dependency array, so it runs once on mount, not when the user copies.

Where:
packages/ui/copy-button.tsx:26-30

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

Steps to reproduce:

  1. Render <CopyButton value="x" />.
  2. Wait more than 2 seconds.
  3. Click the button.

Expected behavior:
The check icon shows for about 2 seconds, then returns to the clipboard icon.

Actual behavior:
The check icon stays forever, because the only timer already fired on mount. Clicking before the mount timer fires has the opposite problem: the icon resets early, at 2s after mount rather than 2s after the click. The timer is also never cleared on unmount.

Suggested fix:
Run the effect on [hasCopied], only start the timeout when hasCopied is true, and return a clearTimeout cleanup. This is the same pattern CopyableCell already uses in packages/ui/copyable-cell.tsx:22-29:

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

Happy to send a PR for this if it's welcome.

Activity

  1. linear-code commented on Oct 5, 2026

    @linear-code
  2. puang59 commented on Oct 5, 2026

    @puang59
    Author

    Closing as not planned: CopyButton is unused, so this doesn't affect anyone today.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions