Merge pull request #20712 from overleaf/dp-click-mini-panel

Clicking on an entry in the mini review panel opens the full panel

GitOrigin-RevId: 4c925435a09f56ae5b02c53951185c67eb0413a2
This commit is contained in:
David 2024-10-04 10:15:46 +01:00 committed by Copybot
parent b2dab4b1c0
commit a40fb42fed

View file

@ -11,6 +11,7 @@ import {
highlightRanges, highlightRanges,
} from '@/features/source-editor/extensions/ranges' } from '@/features/source-editor/extensions/ranges'
import { useEditorManagerContext } from '@/features/ide-react/context/editor-manager-context' import { useEditorManagerContext } from '@/features/ide-react/context/editor-manager-context'
import { useLayoutContext } from '@/shared/context/layout-context'
export const ReviewPanelEntry: FC<{ export const ReviewPanelEntry: FC<{
position: number position: number
@ -34,9 +35,14 @@ export const ReviewPanelEntry: FC<{
const view = useCodeMirrorViewContext() const view = useCodeMirrorViewContext()
const { openDocId } = useEditorManagerContext() const { openDocId } = useEditorManagerContext()
const [focused, setFocused] = useState(false) const [focused, setFocused] = useState(false)
const { setReviewPanelOpen } = useLayoutContext()
const highlighted = isSelectionWithinOp(op, state.selection.main) const highlighted = isSelectionWithinOp(op, state.selection.main)
const openReviewPanel = useCallback(() => {
setReviewPanelOpen(true)
}, [setReviewPanelOpen])
const focusHandler = useCallback(() => { const focusHandler = useCallback(() => {
if (selectLineOnFocus) { if (selectLineOnFocus) {
openDocId(docId, { gotoOffset: position, keepCurrentView: true }) openDocId(docId, { gotoOffset: position, keepCurrentView: true })
@ -55,6 +61,7 @@ export const ReviewPanelEntry: FC<{
return ( return (
<div <div
onMouseDown={openReviewPanel} // Using onMouseDown rather than onClick to guarantee that it fires before onFocus
onFocus={focusHandler} onFocus={focusHandler}
onBlur={() => setFocused(false)} onBlur={() => setFocused(false)}
onMouseEnter={() => { onMouseEnter={() => {