perf: move pr link copy cleanup to button ref

This commit is contained in:
Neil
2026-05-31 09:48:34 -07:00
committed by GitHub
parent 093f068b1a
commit 2be4430d57
@@ -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<void> => {
if (!workItem) {
return