diff --git a/services/web/frontend/js/features/history/extensions/highlight-locations.ts b/services/web/frontend/js/features/history/extensions/highlight-locations.ts index 0e87c833db..9a00b2a253 100644 --- a/services/web/frontend/js/features/history/extensions/highlight-locations.ts +++ b/services/web/frontend/js/features/history/extensions/highlight-locations.ts @@ -125,7 +125,10 @@ export function highlightLocations() { export function scrollToHighlight(view: EditorView, highlight: Highlight) { view.dispatch({ effects: EditorView.scrollIntoView( - EditorSelection.range(highlight.range.from, highlight.range.to) + EditorSelection.range(highlight.range.from, highlight.range.to), + { + y: 'center', + } ), }) } diff --git a/services/web/test/frontend/features/history/components/document-diff-viewer.spec.tsx b/services/web/test/frontend/features/history/components/document-diff-viewer.spec.tsx index f12afa2fa1..40258e3404 100644 --- a/services/web/test/frontend/features/history/components/document-diff-viewer.spec.tsx +++ b/services/web/test/frontend/features/history/components/document-diff-viewer.spec.tsx @@ -203,8 +203,8 @@ End // Click the "More updates above" button, which should scroll the editor up // but not quite to the top, and check the new state cy.get('.previous-highlight-button').first().click() - cy.get('@scroller').invoke('scrollTop').should('not.equal', 0) - cy.get('.previous-highlight-button').should('have.length', 1) + cy.get('@scroller').invoke('scrollTop').should('equal', 0) + cy.get('.previous-highlight-button').should('not.exist') cy.get('.next-highlight-button').should('have.length', 1) })