angular-ui/ui-grid

When restoring scrollFocus, a row that was previously on top, is now on the bottom of grid

Open

#5,911 opened on Dec 22, 2016

View on GitHub
 (1 comment) (0 reactions) (0 assignees)JavaScript (2,496 forks)batch import
help wanted

Repository metrics

Stars
 (5,395 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

I have a grid that's sitting inside a non-modal, I use saveState so I can destroy and recreate the grid.

I'm expecting the row that was the first row to be at the top when restoring, however it appears on the bottom of the grid.

I looked around in ui-grid.js (4.0.1), and noticed that in Grid.prototype.scrollIfNecessary when calculating the "scrollPixels", you deduct(-) the "bottomBound".

If I replace the bottomBound with my rowHeight, I get the expected result.

I might be doing something wrong, but if not, a fix is needed.

EDIT: The issue occurs only when the row that was before on top is below the current view port when restoring the state, as in - pixelsToSeeRow > bottomBound, This is happening in http://ui-grid.info/docs/#/tutorial/208_save_state as well

Contributor guide