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: Double-check optimal size before adding new physical rows (#1755) #1758

Merged
merged 1 commit into from
Jun 16, 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: 1 addition & 1 deletion src/vaadin-grid-scroller.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
estimatedMissingRowCount = Math.max(0, this._effectiveSize - this._physicalCount);
}

if (this._physicalSize && estimatedMissingRowCount > 0) {
if (this._physicalSize && estimatedMissingRowCount > 0 && this._optPhysicalSize !== Infinity) {
super._increasePoolIfNeeded(estimatedMissingRowCount);
// Ensure the rows are in order after increasing pool
this.__reorderChildNodes();
Expand Down
21 changes: 21 additions & 0 deletions test/physical-count.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,28 @@
expect(spy).not.to.be.called;
});

it('should not add unlimited amount of physical rows', () => {
const itemCount = 50;
grid.items = buildDataSet(itemCount);
flushGrid(grid);

// Repro for a really special bug:

// 1: notifyResize will trigger _increasePoolIfNeeded
grid.notifyResize();
// 2: Hide grid
grid.hidden = true;
// 3: notifyResize will trigger updateViewportBoundaries which sets _viewPortHeight to 0 because grid is not rendered
grid.notifyResize();
// 4: Restore grid to render tree
grid.hidden = false;
// 5: Finally flush the grid, and finish the async callback started at phase 1.
// _optPhysicalSize will be Infinity at this point so unlimited amount of rows would get added!
// Only thing that limits it is the grid.items count.
flushGrid(grid);

expect(grid.$.items.childElementCount).to.be.below(itemCount);
});
});
</script>

Expand Down