فهرست منبع

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
Tim Down 3 سال پیش
والد
کامیت
a0e3379c86

+ 4 - 1
services/web/frontend/js/features/history/extensions/highlight-locations.ts

@@ -125,7 +125,10 @@ export function highlightLocations() {
 export function scrollToHighlight(view: EditorView, highlight: Highlight) {
 export function scrollToHighlight(view: EditorView, highlight: Highlight) {
   view.dispatch({
   view.dispatch({
     effects: EditorView.scrollIntoView(
     effects: EditorView.scrollIntoView(
-      EditorSelection.range(highlight.range.from, highlight.range.to)
+      EditorSelection.range(highlight.range.from, highlight.range.to),
+      {
+        y: 'center',
+      }
     ),
     ),
   })
   })
 }
 }

+ 2 - 2
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
     // Click the "More updates above" button, which should scroll the editor up
     // but not quite to the top, and check the new state
     // but not quite to the top, and check the new state
     cy.get('.previous-highlight-button').first().click()
     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)
     cy.get('.next-highlight-button').should('have.length', 1)
   })
   })