Merge pull request #20887 from overleaf/dp-rp-entry-buttons

Don't focus entry if clicking on a button/link

GitOrigin-RevId: 0c37ce76134358ef7d3fd5b0c897ffab8e4d7db1
This commit is contained in:
David 2024-10-08 13:23:30 +01:00 committed by Copybot
parent 43bb8c0ab2
commit d9211998de

View file

@ -43,12 +43,25 @@ export const ReviewPanelEntry: FC<{
setReviewPanelOpen(true) setReviewPanelOpen(true)
}, [setReviewPanelOpen]) }, [setReviewPanelOpen])
const focusHandler = useCallback(() => { 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) { if (selectLineOnFocus) {
openDocId(docId, { gotoOffset: position, keepCurrentView: true }) openDocId(docId, { gotoOffset: position, keepCurrentView: true })
} }
setFocused(true) setFocused(true)
}, [selectLineOnFocus, docId, openDocId, position]) },
[selectLineOnFocus, docId, openDocId, position]
)
// Clear op highlight on dismount // Clear op highlight on dismount
useEffect(() => { useEffect(() => {