From 7a0e1dca994638918c4ebd065753ee0f982dd465 Mon Sep 17 00:00:00 2001 From: Mikey McOrmond Date: Thu, 15 Aug 2019 13:14:30 -0500 Subject: [PATCH] fix(core): scrollToIfNecessary not properly including rowHeight on downward scrolls --- packages/core/src/js/factories/Grid.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/core/src/js/factories/Grid.js b/packages/core/src/js/factories/Grid.js index 71bbdda961..0dd39480e5 100644 --- a/packages/core/src/js/factories/Grid.js +++ b/packages/core/src/js/factories/Grid.js @@ -2332,8 +2332,8 @@ angular.module('ui.grid') /*-- Get the top, left, right, and bottom "scrolled" edges of the grid --*/ - // The top boundary is the current Y scroll position PLUS the header height, because the header can obscure rows when the grid is scrolled downwards - var topBound = self.renderContainers.body.prevScrollTop + self.headerHeight; + // The top boundary is the current Y scroll position + var topBound = self.renderContainers.body.prevScrollTop; // Don't the let top boundary be less than 0 topBound = (topBound < 0) ? 0 : topBound; @@ -2372,7 +2372,7 @@ angular.module('ui.grid') // } // This is the minimum amount of pixels we need to scroll vertical in order to see this row. - var pixelsToSeeRow = (seekRowIndex * self.options.rowHeight + self.headerHeight); + var pixelsToSeeRow = (seekRowIndex * self.options.rowHeight); // Don't let the pixels required to see the row be less than zero pixelsToSeeRow = (pixelsToSeeRow < 0) ? 0 : pixelsToSeeRow; @@ -2399,7 +2399,8 @@ angular.module('ui.grid') // to get the full position we need scrollPixels = pixelsToSeeRow - bottomBound + self.renderContainers.body.prevScrollTop; - scrollEvent.y = getScrollY(scrollPixels, scrollLength,self.renderContainers.body.prevScrolltopPercentage); + // Scroll to full position plus the height of one row since scrollPixels points to the top pixel of the row + scrollEvent.y = getScrollY(scrollPixels + self.options.rowHeight, scrollLength, self.renderContainers.body.prevScrolltopPercentage); } }