This repository was archived by the owner on Sep 5, 2024. It is now read-only.
File tree 2 files changed +27
-2
lines changed
src/components/virtualRepeat
2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -206,14 +206,15 @@ VirtualRepeatContainerController.prototype.sizeScroller_ = function(size) {
206
206
var dimension = this . isHorizontal ( ) ? 'width' : 'height' ;
207
207
var crossDimension = this . isHorizontal ( ) ? 'height' : 'width' ;
208
208
209
+ // Clear any existing dimensions.
210
+ this . sizer . innerHTML = '' ;
211
+
209
212
// If the size falls within the browser's maximum explicit size for a single element, we can
210
213
// set the size and be done. Otherwise, we have to create children that add up the the desired
211
214
// size.
212
215
if ( size < MAX_ELEMENT_SIZE ) {
213
216
this . sizer . style [ dimension ] = size + 'px' ;
214
217
} else {
215
- // Clear any existing dimensions.
216
- this . sizer . innerHTML = '' ;
217
218
this . sizer . style [ dimension ] = 'auto' ;
218
219
this . sizer . style [ crossDimension ] = 'auto' ;
219
220
Original file line number Diff line number Diff line change @@ -285,6 +285,30 @@ describe('<md-virtual-repeat>', function() {
285
285
}
286
286
} ) ;
287
287
288
+ it ( 'should clear scroller if large set of items is filtered to much smaller set' , function ( ) {
289
+ // Create a much larger number of items than will fit in one maximum element size.
290
+ var numItems = 2000000 ;
291
+ createRepeater ( ) ;
292
+ scope . items = createItems ( numItems ) ;
293
+ scope . $apply ( ) ;
294
+ $$rAF . flush ( ) ;
295
+
296
+ // Expect that the sizer as a whole is still exactly the height it should be.
297
+ expect ( sizer [ 0 ] . offsetHeight ) . toBe ( numItems * ITEM_SIZE ) ;
298
+
299
+ // Now that the sizer is really big, change the the number of items to be very small.
300
+ numItems = 2 ;
301
+ scope . items = createItems ( numItems ) ;
302
+ scope . $apply ( ) ;
303
+ $$rAF . flush ( ) ;
304
+
305
+ // Expect that the sizer as a whole is still exactly the height it should be.
306
+ expect ( sizer [ 0 ] . offsetHeight ) . toBe ( numItems * ITEM_SIZE ) ;
307
+
308
+ // Expect that the sizer has no children, as all of items fit comfortably in a single element.
309
+ expect ( sizer [ 0 ] . children . length ) . toBe ( 0 ) ;
310
+ } ) ;
311
+
288
312
it ( 'should start at the given scroll position' , function ( ) {
289
313
scope . startIndex = 10 ;
290
314
scope . items = createItems ( 200 ) ;
You can’t perform that action at this time.
0 commit comments