Cancel rich markdown attention timers from root ref (#3467)

This commit is contained in:
Neil
2026-05-30 14:32:58 -04:00
committed by GitHub
parent 554388b28d
commit 5dddce37b6
@@ -737,6 +737,29 @@ export default function RichMarkdownEditor({
return registerPendingEditorFlush(fileId, flushPendingSerialization)
}, [fileId, flushPendingSerialization])
const clearAttentionTimers = useCallback(() => {
if (attentionReviewCommentTimeoutRef.current !== null) {
window.clearTimeout(attentionReviewCommentTimeoutRef.current)
attentionReviewCommentTimeoutRef.current = null
}
if (sourceAttentionTimeoutRef.current !== null) {
window.clearTimeout(sourceAttentionTimeoutRef.current)
sourceAttentionTimeoutRef.current = null
}
}, [])
const setRootElement = useCallback(
(node: HTMLDivElement | null) => {
// Why: review-note pulses are tied to this editor root; ref cleanup
// keeps the existing unmount boundary without a passive Effect.
if (node === null) {
clearAttentionTimers()
}
rootRef.current = node
},
[clearAttentionTimers]
)
const syncAnnotationTarget = useCallback((nextEditor: Editor): void => {
if (annotationTargetFrameRef.current !== null) {
window.cancelAnimationFrame(annotationTargetFrameRef.current)
@@ -764,17 +787,6 @@ export default function RichMarkdownEditor({
})
}, [])
useEffect(() => {
return () => {
if (attentionReviewCommentTimeoutRef.current !== null) {
window.clearTimeout(attentionReviewCommentTimeoutRef.current)
}
if (sourceAttentionTimeoutRef.current !== null) {
window.clearTimeout(sourceAttentionTimeoutRef.current)
}
}
}, [])
const pulseRichMarkdownReviewNote = useCallback((commentId: string): void => {
if (attentionReviewCommentTimeoutRef.current !== null) {
window.clearTimeout(attentionReviewCommentTimeoutRef.current)
@@ -1689,7 +1701,7 @@ export default function RichMarkdownEditor({
return (
<div className="rich-markdown-editor-layout">
<div
ref={rootRef}
ref={setRootElement}
className={`rich-markdown-editor-shell ${
reviewRailExpanded ? 'has-rich-markdown-review-notes' : ''
}`.trim()}