Explorar o código

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

Clear op highlight on review-panel-entry dismount

GitOrigin-RevId: 9892df75f35fcb0440bd19bcfbaa276a3db033a1
David %!s(int64=2) %!d(string=hai) anos
pai
achega
4480a986a3

+ 10 - 1
services/web/frontend/js/features/review-panel-new/components/review-panel-entry.tsx

@@ -1,4 +1,4 @@
-import { FC, useCallback, useState } from 'react'
+import { FC, useCallback, useEffect, useState } from 'react'
 import { AnyOperation } from '../../../../../types/change'
 import { AnyOperation } from '../../../../../types/change'
 import {
 import {
   useCodeMirrorStateContext,
   useCodeMirrorStateContext,
@@ -44,6 +44,15 @@ export const ReviewPanelEntry: FC<{
     setFocused(true)
     setFocused(true)
   }, [selectLineOnFocus, docId, openDocId, position])
   }, [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 (
   return (
     <div
     <div
       onFocus={focusHandler}
       onFocus={focusHandler}