perf: move pr link copy cleanup to button ref
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user