angular-ui/ui-grid

saveState's saveScrollFocus does not handle saving vertical or horizontal scroll indexes correctly

Open

#5,313 创建于 2016年4月12日

在 GitHub 查看
 (1 评论) (0 反应) (1 负责人)JavaScript (5,395 star) (2,496 fork)batch import
good first issue

描述

When the user scrolls vertically, the GridContainer's prevRowScrollIndex is updated. When the user scrolls horizontally, the GridContainer's prevRowScrollIndex is updated.

If the user does not scroll or scrolls all the way to the top/left, the index is set to 0.

This is an issue when trying to restore the scroll state, because the if statement evaluating the prevRowScrollIndex will return false when the index is 0, because javascript treats 0 as falsy.

I think this should instead check to see that the prevRowScrollIndex is not undefined.

Additionally, this same thing would happen for restoration of the the column scroll and would also need to check to see that it is not undefined.

However, the variable is actually named prevColumnScrollIndex and not prevColScrollIndex like in saveState. So it is currently not working at all.

This should be renamed in one of the two places.


This can be reproduced on a slightly-modified (to add col widths for horizontal scrolling) Save State example/plunkr: http://plnkr.co/edit/bt7az4jSzaH94gYIOz1r?p=preview Steps to recreate vertically:

  1. Do not scroll vertically
  2. Click Save
  3. Scroll vertically to the bottom of the grid
  4. Click Restore. Note the vertically scrolled-to row is still the bottom of the grid and not the top

Steps to recreate horizontally:

  1. Scroll horizontally to right of grid
  2. Click Save
  3. Scroll horizontally back to left of grid
  4. Click Restore. Note that horizontal scroll does not ever change.

贡献者指南