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

Cherrypick: Flush debounceIncreasePool on loadPage (#2131) #2132

Merged
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: 1 addition & 1 deletion src/vaadin-grid-data-provider-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ export const DataProviderMixin = (superClass) =>
filters: this._mapFilters(),
parentItem: cache.parentItem
};

this._debounceIncreasePool && this._debounceIncreasePool.flush();
this.dataProvider(params, (items, size) => {
if (size !== undefined) {
cache.size = size;
Expand Down
2 changes: 1 addition & 1 deletion test/data-provider.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ describe('data provider', () => {
// Effective size should change in between the data requests
expect(renderSpy.called).to.be.true;
expect(increasePoolSpy.callCount).to.above(1);
expect(updateItemSpy.callCount).to.be.below(90);
expect(updateItemSpy.callCount).to.be.below(180);
});

it('should keep item expanded on itemIdPath change', () => {
Expand Down
37 changes: 37 additions & 0 deletions test/scroll-to-index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ const fixtures = {
<template>[[index]]</template>
</vaadin-grid-column>
</vaadin-grid>
`,
treeGrid: `
<vaadin-grid style="width: 200px; height: 500px;">
<vaadin-grid-tree-column path="name" header="foo" item-has-children-path="hasChildren"></vaadin-grid-tree-column>
</vaadin-grid>
`
};

Expand Down Expand Up @@ -203,4 +208,36 @@ describe('scroll to index', () => {
expect(grid.$.items.children[0]._item.index).to.equal(0);
});
});
describe('Tree grid', () => {
// Issue https://github.com/vaadin/vaadin-grid/issues/2107
it('should display correctly when scrolled to bottom immediately after setting dataProvider', (done) => {
const grid = fixtureSync(fixtures.treeGrid);
grid.size = 1;
const numberOfChidren = 250;
grid.itemIdPath = 'name';
const PARENT = { name: 'PARENT', hasChildren: true };
grid.dataProvider = ({ page, parentItem }, cb) => {
setTimeout(() => {
if (!parentItem) {
cb([PARENT], 1);
return;
}

const offset = page * grid.pageSize;
cb(
[...new Array(grid.pageSize)].map((_, index) => {
return { name: 'Child ' + (offset + index), hasChildren: false };
}),
numberOfChidren
);
if (page > 0) {
expect(grid._physicalCount).to.be.above(10);
done();
}
});
};
grid.expandedItems = [PARENT];
grid.scrollToIndex(250);
});
});
});