Skip to content

Commit

Permalink
fix: make explicit data request when clearing cache with no initial p…
Browse files Browse the repository at this point in the history
…ool (#2119) (#2123)

* fix: increase pool before clearing cache when sorting; add test

* Enhance the fix by making explicit data request

* Remove height condition

* Move the test

* Apply Serhii's suggestions

Co-authored-by: Serhii Kulykov <iamkulykov@gmail.com>

* Update test

Co-authored-by: Serhii Kulykov <iamkulykov@gmail.com>

Co-authored-by: Serhii Kulykov <iamkulykov@gmail.com>
  • Loading branch information
yuriy-fix and web-padawan authored Feb 1, 2021
1 parent 2d65df1 commit d7b4777
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
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 @@ -427,7 +427,7 @@
this._hasData = false;
this._assignModels();

if (!this._effectiveSize) {
if (!this._effectiveSize || !this._initialPoolCreated) {
this._loadPage(0, this._cache);
}
}
Expand Down
29 changes: 29 additions & 0 deletions test/data-provider.html
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,35 @@
});
});

describe('attached', () => {

it('should have rows when attached and shown after cache is cleared on hidden grid', done => {
const grid = document.createElement('vaadin-grid');
const col = document.createElement('vaadin-grid-column');
col.setAttribute('path', 'item');
grid.appendChild(col);

grid.size = 1;
grid.dataProvider = function(params, callback) {
callback([{item: 'A'}]);
};

grid.style.display = 'none';
document.body.appendChild(grid);

setTimeout(() => {
grid.clearCache();
grid.removeAttribute('style');
expect(getCellContent(getFirstVisibleItem(grid)).textContent).to.equal('A');

// Grid should be removed after test as was attached to body.
document.body.removeChild(grid);
done();
});
});

});

describe('fixture table', () => {
let container, grid;

Expand Down

0 comments on commit d7b4777

Please sign in to comment.