Skip to content

Commit

Permalink
Merge pull request #1239 from vaadin/fix-init-performance
Browse files Browse the repository at this point in the history
Don't render empty rows if columns haven't yet initialized
  • Loading branch information
tomivirkki authored Mar 6, 2018
2 parents bb2bc8f + 86e6467 commit 2801da0
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 12 deletions.
6 changes: 1 addition & 5 deletions demo/grid-pagination-demos.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ <h3>Pagination</h3>
<dom-module id="x-pagination">
<template preserve-content>
<style>
vaadin-grid {
height: auto;
}

#pages {
display: flex;
flex-wrap: wrap;
Expand Down Expand Up @@ -59,7 +55,7 @@ <h3>Pagination</h3>
</style>
<x-array-data-provider items="{{items}}"></x-array-data-provider>

<vaadin-grid id="grid" page-size="10">
<vaadin-grid id="grid" page-size="10" height-by-rows>

<vaadin-grid-column>
<template class="header">First Name</template>
Expand Down
2 changes: 1 addition & 1 deletion src/vaadin-grid-data-provider-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
}

_canPopulate() {
return this._hasData;
return this._hasData && this._columnTree;
}

_loadPage(page, cache) {
Expand Down
2 changes: 2 additions & 0 deletions src/vaadin-grid-dynamic-columns-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
this._debouncerCheckImports,
Polymer.Async.timeOut.after(2000),
this._checkImports.bind(this));

this._ensureFirstPageLoaded();
});
}

Expand Down
1 change: 1 addition & 0 deletions test/array-data-provider.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
grid = fixture('default');
grid.items = [];
grid.items = [0];
flushGrid(grid);
expect(getRows(grid.$.items)).to.have.length(1);
});

Expand Down
2 changes: 1 addition & 1 deletion test/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@

it('Should change the opacity of cell content in loading rows from 1 to 0 and back', () => {
const firstRow = grid.shadowRoot.querySelector('#items [part~="row"]');
const cellContent = grid.querySelector('vaadin-grid-cell-content');
const cellContent = getBodyCellContent(grid, 0, 0);

expect(window.getComputedStyle(cellContent).opacity).to.eql('1');

Expand Down
7 changes: 7 additions & 0 deletions test/data-provider.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@
flushGrid(grid);
});

it('should not render rows before columns are defined', () => {
container = fixture('table');
grid = container.$.grid;
container.dataProvider = sinon.spy(infiniteDataProvider);
expect(grid.$.items.childElementCount).to.equal(0);
});

it('should call dataprovider for first page', done => {
container.dataProvider.reset();
grid.pageSize = 100;
Expand Down
4 changes: 1 addition & 3 deletions test/outer-scroller.html
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,7 @@

grid = fixture('scrollable-content');

if (Polymer.Element) {
flushColumns(grid);
}
flushGrid(grid);

grid.dataProvider = infiniteDataProvider;
Polymer.dom.flush();
Expand Down
2 changes: 1 addition & 1 deletion test/row-details.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@

grid = fixture('default');
grid.dataProvider = infiniteDataProvider;
Polymer.dom.flush();
flushGrid(grid);
bodyRows = getRows(grid.$.items);
animationFrameFlush(() => done());
});
Expand Down
2 changes: 1 addition & 1 deletion test/templates.html
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
div = bind.$.div;
grid = bind.$.grid;
flushGrid(bind.$.grid);
input = grid.querySelector('input');
input = getBodyCellContent(grid, 0, 0).querySelector('input');
});

it('should notify items array path', () => {
Expand Down

0 comments on commit 2801da0

Please sign in to comment.