mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -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
|
return () => {
|
||||||
if (element) {
|
if (containerRef.current) {
|
||||||
element.addEventListener('review-panel:position', updatePositions)
|
containerRef.current.removeEventListener(
|
||||||
// view.scrollDOM.addEventListener('scroll', positionListener)
|
'review-panel:position',
|
||||||
return () => {
|
updatePositions
|
||||||
element.removeEventListener('review-panel:position', updatePositions)
|
)
|
||||||
// view.scrollDOM.removeEventListener('scroll', positionListener)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [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