From 7c613cdceb337c78018ca51920e515f145ec2466 Mon Sep 17 00:00:00 2001 From: David <33458145+davidmcpowell@users.noreply.github.com> Date: Mon, 28 Oct 2024 15:38:51 +0000 Subject: [PATCH] Merge pull request #21438 from overleaf/dp-edit-comment-popover Dont select entry from textarea when review panel is mini GitOrigin-RevId: 5900ae11ec01bb40100e19497557469e6dac1615 --- .../components/review-panel-entry.tsx | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/services/web/frontend/js/features/review-panel-new/components/review-panel-entry.tsx b/services/web/frontend/js/features/review-panel-new/components/review-panel-entry.tsx index 4c2d10e23e..ed79727622 100644 --- a/services/web/frontend/js/features/review-panel-new/components/review-panel-entry.tsx +++ b/services/web/frontend/js/features/review-panel-new/components/review-panel-entry.tsx @@ -47,8 +47,7 @@ export const ReviewPanelEntry: FC<{ const { openDocId, getCurrentDocId } = useEditorManagerContext() const [selected, setSelected] = useState(false) const [focused, setFocused] = useState(false) - const { setReviewPanelOpen } = useLayoutContext() - + const { setReviewPanelOpen, reviewPanelOpen } = useLayoutContext() const highlighted = isSelectionWithinOp(op, state.selection.main) const openReviewPanel = useCallback(() => { @@ -62,10 +61,11 @@ export const ReviewPanelEntry: FC<{ if ( event.target instanceof HTMLButtonElement || event.target instanceof HTMLLinkElement || - event.target instanceof HTMLAnchorElement + event.target instanceof HTMLAnchorElement || + (event.target instanceof HTMLTextAreaElement && !reviewPanelOpen) ) { - // Don't focus if the click was on a button/link/anchor as we - // don't want to affect its behaviour + // Ignore focus events on certain elements so as to not affect + // their behavior return } @@ -89,7 +89,15 @@ export const ReviewPanelEntry: FC<{ ) } }, - [getCurrentDocId, docId, selectLineOnFocus, view, position, openDocId] + [ + getCurrentDocId, + docId, + selectLineOnFocus, + view, + position, + openDocId, + reviewPanelOpen, + ] ) // Clear op highlight on dismount