Skip to content

Commit

Permalink
Add test and fix scroll to
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriy-fix committed Oct 26, 2020
1 parent 98deb3f commit 0c8de60
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/vaadin-grid-scroll-mixin.html
Expand Up @@ -130,6 +130,10 @@
* @param {number} index Row index to scroll to
*/
scrollToIndex(index) {
if (index > this._physicalCount) {
this._increasePoolIfNeeded(0);
this._debounceIncreasePool && this._debounceIncreasePool.flush();
}
this._accessIronListAPI(() => super.scrollToIndex(index));
}

Expand Down
20 changes: 20 additions & 0 deletions test/scroll-to-index.html
Expand Up @@ -150,6 +150,26 @@

});

describe('Physical pool', () => {
let grid, scroller, data;

beforeEach(() => {
grid = fixture('large');
data = Array(...new Array(200)).map((_, i) => {
return {'index': i};
});
grid.items = data.splice(0, 10);
flushGrid(grid);
});

it('should scroll to pushed index', () => {
grid.push('items', data[grid.items.length]);
grid.scrollToIndex(grid.items.length);

expect(grid.$.items.children[0]._item.index).to.equal(0);
});
});

});
</script>

Expand Down

0 comments on commit 0c8de60

Please sign in to comment.