From c503083e5e084c41db864ffaeb8c995ada4fa86a Mon Sep 17 00:00:00 2001 From: Tim Down <158919+timdown@users.noreply.github.com> Date: Thu, 4 May 2023 10:57:48 +0100 Subject: [PATCH] Merge pull request #12939 from overleaf/td-history-more-update-scroll-amount History migration: More update button scrolls next change to the centre GitOrigin-RevId: 29d41a046f7110c246a0b9c784dedf6b148ea298 --- .../js/features/history/extensions/highlight-locations.ts | 5 ++++- .../history/components/document-diff-viewer.spec.tsx | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) 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) })