mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
Merge pull request #32641 from overleaf/ab-hide-add-comment-tooltip-on-blur
[web] Hide add comment tooltip when clicking outside the editor GitOrigin-RevId: beff4c2e54fd28e47028f2bbc586f26fe6d3cc1d
This commit is contained in:
committed by
Copybot
parent
256532b13c
commit
bac2f5e2fc
@@ -60,6 +60,27 @@ const ReviewTooltipMenu: FC = () => {
|
||||
}
|
||||
}, [tooltipState, previousTooltipState])
|
||||
|
||||
useEffect(() => {
|
||||
if (!show || !tooltipState || !permissions.comment) {
|
||||
return
|
||||
}
|
||||
const handleMouseDown = (event: MouseEvent) => {
|
||||
const target = event.target as Element | null
|
||||
if (
|
||||
!view.contentDOM.contains(target) &&
|
||||
!target?.closest?.('.review-tooltip-menu-container') &&
|
||||
!target?.closest?.('.modal') &&
|
||||
!target?.closest?.('.modal-backdrop')
|
||||
) {
|
||||
setShow(false)
|
||||
}
|
||||
}
|
||||
document.addEventListener('mousedown', handleMouseDown)
|
||||
return () => {
|
||||
document.removeEventListener('mousedown', handleMouseDown)
|
||||
}
|
||||
}, [show, tooltipState, permissions.comment, view])
|
||||
|
||||
const addComment = useCallback(() => {
|
||||
if (!permissions.comment) {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user