Merge pull request #20785 from overleaf/dp-sticky-highlights

Clear op highlight on review-panel-entry dismount

GitOrigin-RevId: 9892df75f35fcb0440bd19bcfbaa276a3db033a1
This commit is contained in:
David 2024-10-04 10:15:31 +01:00 committed by Copybot
parent 551de499d5
commit 4480a986a3

View file

@ -1,4 +1,4 @@
import { FC, useCallback, useState } from 'react'
import { FC, useCallback, useEffect, useState } from 'react'
import { AnyOperation } from '../../../../../types/change'
import {
useCodeMirrorStateContext,
@ -44,6 +44,15 @@ export const ReviewPanelEntry: FC<{
setFocused(true)
}, [selectLineOnFocus, docId, openDocId, position])
// Clear op highlight on dismount
useEffect(() => {
return () => {
if (hoverRanges) {
view.dispatch(clearHighlightRanges(op))
}
}
}, []) // eslint-disable-line react-hooks/exhaustive-deps
return (
<div
onFocus={focusHandler}