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 206
206
} ;
207
207
} ) ;
208
208
209
+ it ( 'should not request to load page for previous viewport when clearing items from cache' , ( ) => {
210
+ grid . dataProvider = sinon . spy ( infiniteDataProvider ) ;
211
+ // Clear initial data provider request from spy
212
+ grid . dataProvider . reset ( ) ;
213
+ // Remove item from current viewport from cache
214
+ // This simulates Flow component behavior, which clears pages for the
215
+ // previous viewport after loading pages for the new viewport
216
+ delete grid . _cache . items [ 0 ] ;
217
+
218
+ // Scroll to new viewport
219
+ grid . scrollToIndex ( 1000 ) ;
220
+
221
+ // Verify data provider was not called with page for previous viewport (page 0)
222
+ grid . dataProvider . args . forEach ( args => {
223
+ expect ( args [ 0 ] . page ) . not . to . eql ( 0 ) ;
224
+ } ) ;
225
+ } ) ;
226
+
209
227
} ) ;
210
228
211
229
describe ( 'Added item' , ( ) => {
You can’t perform that action at this time.
0 commit comments