mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-07 16:19:02 +02:00
Change scrollTo behavior when review panel entry is selected (#23720)
GitOrigin-RevId: 86fc08f437c49bdf00a9b7d8461b9476f2e9717f
This commit is contained in:
committed by
Copybot
parent
3deeda447b
commit
8b454f5d24
+10
-4
@@ -13,7 +13,6 @@ import {
|
||||
import { useEditorManagerContext } from '@/features/ide-react/context/editor-manager-context'
|
||||
import { useLayoutContext } from '@/shared/context/layout-context'
|
||||
import { EditorSelection } from '@codemirror/state'
|
||||
import { EditorView } from '@codemirror/view'
|
||||
import MaterialIcon from '@/shared/components/material-icon'
|
||||
import { OFFSET_FOR_ENTRIES_ABOVE } from '../utils/position-items'
|
||||
|
||||
@@ -92,12 +91,19 @@ export const ReviewPanelEntry: FC<{
|
||||
if (getCurrentDocumentId() !== docId) {
|
||||
openDocWithId(docId, { gotoOffset: position, keepCurrentView: true })
|
||||
} else {
|
||||
setTimeout(() =>
|
||||
setTimeout(() => {
|
||||
view.dispatch({
|
||||
selection: EditorSelection.cursor(position),
|
||||
effects: EditorView.scrollIntoView(position, { y: 'center' }),
|
||||
})
|
||||
)
|
||||
|
||||
// scroll to line (centered)
|
||||
const blockInfo = view.lineBlockAt(position)
|
||||
const editorHeight = view.scrollDOM.getBoundingClientRect().height
|
||||
view.scrollDOM.scrollTo({
|
||||
top: blockInfo.top - editorHeight / 2 + blockInfo.height,
|
||||
behavior: 'smooth',
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user