diff --git a/src/renderer/src/components/PullRequestPage.tsx b/src/renderer/src/components/PullRequestPage.tsx index 18dac2c4d..a41ae4d8a 100644 --- a/src/renderer/src/components/PullRequestPage.tsx +++ b/src/renderer/src/components/PullRequestPage.tsx @@ -5410,17 +5410,23 @@ export default function PullRequestPage({ window.clearTimeout(linkCopiedResetTimerRef.current) linkCopiedResetTimerRef.current = null }, []) - const setLinkCopyButtonRef = useCallback((node: HTMLButtonElement | null) => { - linkCopyMountedRef.current = node !== null - }, []) + const setLinkCopyButtonRef = useCallback( + (node: HTMLButtonElement | null) => { + linkCopyMountedRef.current = node !== null + if (node === null) { + // Why: the copied-state timer belongs to the copy control surface; + // clear it when that surface detaches without a passive cleanup Effect. + clearLinkCopiedResetTimer() + } + }, + [clearLinkCopiedResetTimer] + ) useEffect(() => { clearLinkCopiedResetTimer() setLinkCopied(false) }, [clearLinkCopiedResetTimer, workItemId]) - useEffect(() => clearLinkCopiedResetTimer, [clearLinkCopiedResetTimer]) - const handleCopyWorkItemLink = useCallback(async (): Promise => { if (!workItem) { return