Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scroll to added item #2067

Merged
merged 2 commits into from
Oct 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/vaadin-grid-data-provider-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@
this._cache.size += delta;
this._cache.effectiveSize += delta;
this._effectiveSize = this._cache.effectiveSize;
this._increasePoolIfNeeded(0);
this._debounceIncreasePool && this._debounceIncreasePool.flush();
}

/**
Expand Down
4 changes: 0 additions & 4 deletions test/physical-count.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@

it('increase pool size after resizing the scroller', () => {
grid.classList.add('small');
// Workaround for FF58 rendering issue
grid.size = 0;
grid.size = 200;

grid.style.display = 'none';

expect(grid._physicalItems.length).to.eql(25);
Expand Down
27 changes: 27 additions & 0 deletions test/scroll-to-index.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,33 @@

});

describe('Added item', () => {
let grid, scroller, data;

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

grid.size = 10;
grid.dataProvider = function(params, callback) {
callback(data);
};

flushGrid(grid);
});

it('should not reassign the first item on scrollToIndex', () => {
const newExpectedSize = grid.size + 1;
grid.size = newExpectedSize;
data.push({'index': 11});
grid.scrollToIndex(grid.items.length);

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

});
</script>

Expand Down