From f18d01ec758ee26e5739b7d7bc607c4c8d0b0eeb Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Fri, 29 May 2026 17:50:42 -0700 Subject: [PATCH] Move checks panel copy timer into handler (#3394) --- .../right-sidebar/checks-panel-content.tsx | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/renderer/src/components/right-sidebar/checks-panel-content.tsx b/src/renderer/src/components/right-sidebar/checks-panel-content.tsx index 24bee80a4f1..ec42d2669e8 100644 --- a/src/renderer/src/components/right-sidebar/checks-panel-content.tsx +++ b/src/renderer/src/components/right-sidebar/checks-panel-content.tsx @@ -1,6 +1,6 @@ /* eslint-disable max-lines -- Why: co-locating all checks-panel sub-components (checks list, conflict sections, threaded PR comments) keeps the shared icon/color maps in one place. */ -import React, { useCallback, useEffect, useState } from 'react' +import React, { useCallback, useEffect, useRef, useState } from 'react' import { CircleCheck, CircleX, @@ -356,23 +356,28 @@ export function ChecksList({ function CopyButton({ text }: { text: string }): React.JSX.Element { const [copied, setCopied] = useState(false) + const copiedResetTimerRef = useRef(null) - useEffect(() => { - if (!copied) { - return + const clearCopiedResetTimer = useCallback((): void => { + if (copiedResetTimerRef.current !== null) { + window.clearTimeout(copiedResetTimerRef.current) + copiedResetTimerRef.current = null } - const timeout = window.setTimeout(() => setCopied(false), 1500) - return () => window.clearTimeout(timeout) - }, [copied]) + }, []) const handleCopy = useCallback( (e: React.MouseEvent) => { e.stopPropagation() void window.api.ui.writeClipboardText(text).then(() => { + clearCopiedResetTimer() setCopied(true) + copiedResetTimerRef.current = window.setTimeout(() => { + copiedResetTimerRef.current = null + setCopied(false) + }, 1500) }) }, - [text] + [clearCopiedResetTimer, text] ) return (