From 7fa84e0b840da767abfe1638baf62c1e166d2b8c Mon Sep 17 00:00:00 2001
From: Tulio Garcia <28783969+tulioag@users.noreply.github.com>
Date: Thu, 18 Feb 2021 13:24:24 +0200
Subject: [PATCH 1/2] fix: Flush debounceIncreasePool on loadPage
cherrypick: #2131
fixes: #2107
Warranty: Fixes TreeGrid regression where blank areas are displayed when an initial scroll happens.
---
src/vaadin-grid-data-provider-mixin.js | 2 +-
test/data-provider.test.js | 2 +-
test/scroll-to-index.test.js | 37 ++++++++++++++++++++++++++
3 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/src/vaadin-grid-data-provider-mixin.js b/src/vaadin-grid-data-provider-mixin.js
index f7268ec20..0881b565b 100644
--- a/src/vaadin-grid-data-provider-mixin.js
+++ b/src/vaadin-grid-data-provider-mixin.js
@@ -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;
diff --git a/test/data-provider.test.js b/test/data-provider.test.js
index 95b24e14a..44c80dc3a 100644
--- a/test/data-provider.test.js
+++ b/test/data-provider.test.js
@@ -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', () => {
diff --git a/test/scroll-to-index.test.js b/test/scroll-to-index.test.js
index 319cc2544..6a9abbbe2 100644
--- a/test/scroll-to-index.test.js
+++ b/test/scroll-to-index.test.js
@@ -19,6 +19,11 @@ const fixtures = {
[[index]]
+ `,
+ treeGrid: `
+
+
+
`
};
@@ -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 = 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);
+ });
+ });
});
From 7e6da75a4aae9b3b05de6cfdbc72cdb26c6ea70d Mon Sep 17 00:00:00 2001
From: Tulio Garcia <28783969+tulioag@users.noreply.github.com>
Date: Thu, 18 Feb 2021 14:10:07 +0200
Subject: [PATCH 2/2] fix tests
---
test/scroll-to-index.test.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/scroll-to-index.test.js b/test/scroll-to-index.test.js
index 6a9abbbe2..c90c308d4 100644
--- a/test/scroll-to-index.test.js
+++ b/test/scroll-to-index.test.js
@@ -211,7 +211,7 @@ describe('scroll to index', () => {
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 = fixtures.treeGrid;
+ const grid = fixtureSync(fixtures.treeGrid);
grid.size = 1;
const numberOfChidren = 250;
grid.itemIdPath = 'name';