Skip to content

bug: "copied" success indicator never auto-resets in LandingPageClient (commented-out timeout) #6248

@nishupr

Description

@nishupr

Problem
In app/components/LandingPageClient.tsx, after a successful clipboard copy, setCopied(true) is called, but the corresponding reset timeout is commented out:

setCopied(true);
scrollTimeoutRef.current = setTimeout(() => {
guideRef.current?.scrollIntoView({ behavior: 'smooth', block: 'start' });
}, 80);
//if (copiedTimeoutRef.current) clearTimeout(copiedTimeoutRef.current);
//copiedTimeoutRef.current = setTimeout(() => setCopied(false), 3000);

As a result, the "copied" success indicator stays visible indefinitely after a copy action, instead of auto-dismissing after ~3 seconds like the equivalent pattern in other components across the codebase (e.g. app/compare/CompareClient.tsx, app/customize/page.tsx, app/generator/components/PreviewPanel.tsx, app/documentation/code-block.tsx, components/dashboard/ProfileOptimizerModal.tsx — all of which call setTimeout(() => setCopied(false), ...) after setCopied(true)).

The component does have a ref (copiedTimeoutRef) and a cleanup effect that clears it on unmount, but since the timeout is never actually scheduled, the cleanup has nothing to clear, and the UI state never resets during normal usage.

Root cause
The auto-reset setTimeout call was commented out (likely during debugging or a refactor) and never restored.

Proposed fix
Uncomment and restore the timeout, consistent with the pattern used elsewhere in the codebase:

setCopied(true);
scrollTimeoutRef.current = setTimeout(() => {
guideRef.current?.scrollIntoView({ behavior: 'smooth', block: 'start' });
}, 80);
if (copiedTimeoutRef.current) clearTimeout(copiedTimeoutRef.current);
copiedTimeoutRef.current = setTimeout(() => setCopied(false), 3000);

This restores the auto-dismiss behavior and makes use of the existing copiedTimeoutRef and cleanup logic that are already in place but currently unused.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions