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])
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(() => {