mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
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:
parent
43bb8c0ab2
commit
d9211998de
1 changed files with 19 additions and 6 deletions
|
@ -43,12 +43,25 @@ export const ReviewPanelEntry: FC<{
|
||||||
setReviewPanelOpen(true)
|
setReviewPanelOpen(true)
|
||||||
}, [setReviewPanelOpen])
|
}, [setReviewPanelOpen])
|
||||||
|
|
||||||
const focusHandler = useCallback(() => {
|
const focusHandler = useCallback(
|
||||||
if (selectLineOnFocus) {
|
event => {
|
||||||
openDocId(docId, { gotoOffset: position, keepCurrentView: true })
|
if (
|
||||||
}
|
event.target instanceof HTMLButtonElement ||
|
||||||
setFocused(true)
|
event.target instanceof HTMLLinkElement ||
|
||||||
}, [selectLineOnFocus, docId, openDocId, position])
|
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
|
// Clear op highlight on dismount
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
Loading…
Reference in a new issue