File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 82
82
this . _scrollingToIndex = true ;
83
83
index = Math . min ( Math . max ( index , 0 ) , this . _effectiveSize - 1 ) ;
84
84
this . $ . table . scrollTop = index / this . _effectiveSize * ( this . $ . table . scrollHeight - this . $ . table . offsetHeight ) ;
85
+
86
+ // We need to run the iron-list scroll handler here in order to recalculate the scaling from effective size to
87
+ // virtual size after changing the scroll position. However we don't want to trigger updates to the items / rows
88
+ // in this step, which could result in data provider requests for the previous viewport
89
+ this . _preventItemUpdates = true ;
85
90
this . _scrollHandler ( ) ;
91
+ this . _preventItemUpdates = false ;
86
92
87
93
if ( this . _accessIronListAPI ( ( ) => this . _maxScrollTop ) && this . _virtualCount < this . _effectiveSize ) {
88
94
this . _adjustVirtualIndexOffset ( 1000000 ) ;
259
265
* @protected
260
266
*/
261
267
_assignModels ( itemSet ) {
268
+ // Skip here if internal flag for preventing item updates is set
269
+ if ( this . _preventItemUpdates ) {
270
+ return ;
271
+ }
262
272
this . _iterateItems ( ( pidx , vidx ) => {
263
273
const el = this . _physicalItems [ pidx ] ;
264
274
this . _toggleAttribute ( 'hidden' , vidx >= this . _effectiveSize , el ) ;
Original file line number Diff line number Diff line change 207
207
} ;
208
208
} ) ;
209
209
210
+ it ( 'should not request to load page for previous viewport when clearing items from cache' , ( ) => {
211
+ grid . dataProvider = sinon . spy ( infiniteDataProvider ) ;
212
+ // Clear initial data provider request from spy
213
+ grid . dataProvider . reset ( ) ;
214
+ // Remove item from current viewport from cache
215
+ // This simulates Flow component behavior, which clears pages for the
216
+ // previous viewport after loading pages for the new viewport
217
+ delete grid . _cache . items [ 0 ] ;
218
+
219
+ // Scroll to new viewport
220
+ grid . scrollToIndex ( 1000 ) ;
221
+
222
+ // Verify data provider was not called with page for previous viewport (page 0)
223
+ grid . dataProvider . args . forEach ( args => {
224
+ expect ( args [ 0 ] . page ) . not . to . eql ( 0 ) ;
225
+ } ) ;
226
+ } ) ;
227
+
210
228
} ) ;
211
229
212
230
describe ( 'Added item' , ( ) => {
You can’t perform that action at this time.
0 commit comments