mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-28 21:53:25 -05:00
Merge pull request #20007 from overleaf/ae-review-panel-container-ref
Fix event listener attachment to review panel container GitOrigin-RevId: ceb1023d7be48d9b88e725963124cd04e98127bd
This commit is contained in:
parent
7e187d903b
commit
ee8b8d0692
1 changed files with 21 additions and 9 deletions
|
@ -100,17 +100,29 @@ const ReviewPanelCurrentFile: FC = () => {
|
||||||
}
|
}
|
||||||
}, [state, updatePositions])
|
}, [state, updatePositions])
|
||||||
|
|
||||||
|
const handleContainer = useCallback(
|
||||||
|
(element: HTMLDivElement | null) => {
|
||||||
|
containerRef.current = element
|
||||||
|
if (containerRef.current) {
|
||||||
|
containerRef.current.addEventListener(
|
||||||
|
'review-panel:position',
|
||||||
|
updatePositions
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[updatePositions]
|
||||||
|
)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const element = containerRef.current
|
|
||||||
if (element) {
|
|
||||||
element.addEventListener('review-panel:position', updatePositions)
|
|
||||||
// view.scrollDOM.addEventListener('scroll', positionListener)
|
|
||||||
return () => {
|
return () => {
|
||||||
element.removeEventListener('review-panel:position', updatePositions)
|
if (containerRef.current) {
|
||||||
// view.scrollDOM.removeEventListener('scroll', positionListener)
|
containerRef.current.removeEventListener(
|
||||||
|
'review-panel:position',
|
||||||
|
updatePositions
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [view, updatePositions])
|
}, [updatePositions])
|
||||||
|
|
||||||
const buildEntries = useCallback(() => {
|
const buildEntries = useCallback(() => {
|
||||||
if (ranges) {
|
if (ranges) {
|
||||||
|
@ -194,7 +206,7 @@ const ReviewPanelCurrentFile: FC = () => {
|
||||||
rangesWithPositions.comments.length === 0
|
rangesWithPositions.comments.length === 0
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={containerRef}>
|
<div ref={handleContainer}>
|
||||||
{selectionCoords && (
|
{selectionCoords && (
|
||||||
<div
|
<div
|
||||||
className="review-panel-entry"
|
className="review-panel-entry"
|
||||||
|
|
Loading…
Reference in a new issue