From 0ea930d9acac0244e7c4a4b550e558dae190411d Mon Sep 17 00:00:00 2001 From: Tomi Virkki Date: Fri, 17 Jan 2025 09:17:10 +0200 Subject: [PATCH] fix: ensure grid root cache has a valid size (#8525) --- packages/grid/src/vaadin-grid-data-provider-mixin.js | 2 +- packages/grid/test/data-provider.common.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/grid/src/vaadin-grid-data-provider-mixin.js b/packages/grid/src/vaadin-grid-data-provider-mixin.js index 3104a43c85c..4cb6f0bbefc 100644 --- a/packages/grid/src/vaadin-grid-data-provider-mixin.js +++ b/packages/grid/src/vaadin-grid-data-provider-mixin.js @@ -384,7 +384,7 @@ export const DataProviderMixin = (superClass) => */ clearCache() { this._dataProviderController.clearCache(); - this._dataProviderController.rootCache.size = this.size; + this._dataProviderController.rootCache.size = this.size || 0; this._dataProviderController.recalculateFlatSize(); this._hasData = false; this.__updateVisibleRows(); diff --git a/packages/grid/test/data-provider.common.js b/packages/grid/test/data-provider.common.js index 27ed80719e7..2241c56304d 100644 --- a/packages/grid/test/data-provider.common.js +++ b/packages/grid/test/data-provider.common.js @@ -533,6 +533,13 @@ describe('data provider', () => { } }); + it('should not jam on clear cache', () => { + grid.dataProvider = (params, callback) => { + setTimeout(() => finiteDataProvider(params, callback), 0); + }; + grid.clearCache(); + }); + it('should not render synchronously until all data requests have finished', (done) => { generateItemIds = true; grid.itemIdPath = 'id';