From d9211998deca60cda0f1530f4c1bebb45058855f Mon Sep 17 00:00:00 2001 From: David <33458145+davidmcpowell@users.noreply.github.com> Date: Tue, 8 Oct 2024 13:23:30 +0100 Subject: [PATCH] Merge pull request #20887 from overleaf/dp-rp-entry-buttons Don't focus entry if clicking on a button/link GitOrigin-RevId: 0c37ce76134358ef7d3fd5b0c897ffab8e4d7db1 --- .../components/review-panel-entry.tsx | 25 ++++++++++++++----- 1 file changed, 19 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 708c083df0..021d7c9ce6 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 @@ -43,12 +43,25 @@ export const ReviewPanelEntry: FC<{ setReviewPanelOpen(true) }, [setReviewPanelOpen]) - const focusHandler = useCallback(() => { - if (selectLineOnFocus) { - openDocId(docId, { gotoOffset: position, keepCurrentView: true }) - } - setFocused(true) - }, [selectLineOnFocus, docId, openDocId, position]) + const focusHandler = useCallback( + event => { + if ( + event.target instanceof HTMLButtonElement || + event.target instanceof HTMLLinkElement || + event.target instanceof HTMLTextAreaElement + ) { + // Don't focus if the click was on a button/link/textarea as we don't want + // affect the behaviour of the button/link/textarea + return + } + + if (selectLineOnFocus) { + openDocId(docId, { gotoOffset: position, keepCurrentView: true }) + } + setFocused(true) + }, + [selectLineOnFocus, docId, openDocId, position] + ) // Clear op highlight on dismount useEffect(() => {