Skip to content

Commit 22ee36b

Browse files
fix: make explicit data request when clearing cache with no initial pool (#2119)
* 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 <[email protected]> * Update test Co-authored-by: Serhii Kulykov <[email protected]>
1 parent 27a3443 commit 22ee36b

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/vaadin-grid-data-provider-mixin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ export const DataProviderMixin = (superClass) =>
420420
this._hasData = false;
421421
this._assignModels();
422422

423-
if (!this._effectiveSize) {
423+
if (!this._effectiveSize || !this._initialPoolCreated) {
424424
this._loadPage(0, this._cache);
425425
}
426426
}

test/data-provider.test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
getCellContent,
99
getContainerCell,
1010
getFirstCell,
11+
getFirstVisibleItem,
1112
getRows,
1213
getRowCells,
1314
infiniteDataProvider,
@@ -563,6 +564,32 @@ describe('data provider', () => {
563564
});
564565
});
565566

567+
describe('attached', () => {
568+
it('should have rows when attached and shown after cache is cleared on hidden grid', async () => {
569+
const grid = document.createElement('vaadin-grid');
570+
const col = document.createElement('vaadin-grid-column');
571+
col.setAttribute('path', 'item');
572+
grid.appendChild(col);
573+
574+
grid.size = 1;
575+
grid.dataProvider = function (params, callback) {
576+
callback([{ item: 'A' }]);
577+
};
578+
579+
grid.style.display = 'none';
580+
document.body.appendChild(grid);
581+
582+
await aTimeout(0);
583+
584+
grid.clearCache();
585+
grid.removeAttribute('style');
586+
expect(getCellContent(getFirstVisibleItem(grid)).textContent).to.equal('A');
587+
588+
// Grid should be removed after test as was attached to body.
589+
document.body.removeChild(grid);
590+
});
591+
});
592+
566593
describe('page size grid', () => {
567594
it('should render grid rows when setting page-size before size', () => {
568595
const container = fixtureSync('<page-size-grid></page-size-grid>');

0 commit comments

Comments
 (0)