@@ -1446,14 +1446,14 @@ it('renders windowSize derived region at bottom', () => {
1446
1446
} ) ;
1447
1447
1448
1448
it ( 'keeps last focused item rendered' , ( ) => {
1449
- const items = generateItems ( 20 ) ;
1449
+ const items = generateItems ( 40 ) ;
1450
1450
const ITEM_HEIGHT = 10 ;
1451
1451
1452
1452
let component ;
1453
1453
ReactTestRenderer . act ( ( ) => {
1454
1454
component = ReactTestRenderer . create (
1455
1455
< VirtualizedList
1456
- initialNumToRender = { 1 }
1456
+ initialNumToRender = { 5 }
1457
1457
windowSize = { 1 }
1458
1458
{ ...baseItemProps ( items ) }
1459
1459
{ ...fixedHeightItemLayoutProps ( ITEM_HEIGHT ) }
@@ -1464,39 +1464,45 @@ it('keeps last focused item rendered', () => {
1464
1464
ReactTestRenderer . act ( ( ) => {
1465
1465
simulateLayout ( component , {
1466
1466
viewport : { width : 10 , height : 50 } ,
1467
- content : { width : 10 , height : 200 } ,
1467
+ content : { width : 10 , height : 400 } ,
1468
1468
} ) ;
1469
1469
1470
1470
performAllBatches ( ) ;
1471
1471
} ) ;
1472
1472
1473
1473
ReactTestRenderer . act ( ( ) => {
1474
- component . getInstance ( ) . _onCellFocusCapture ( 3 ) ;
1474
+ simulateScroll ( component , { x : 0 , y : 100 } ) ;
1475
+ performAllBatches ( ) ;
1475
1476
} ) ;
1476
1477
1477
1478
ReactTestRenderer . act ( ( ) => {
1478
- simulateScroll ( component , { x : 0 , y : 150 } ) ;
1479
+ component . getInstance ( ) . _onCellFocusCapture ( 10 ) ;
1480
+ } ) ;
1481
+
1482
+ ReactTestRenderer . act ( ( ) => {
1483
+ simulateScroll ( component , { x : 0 , y : 350 } ) ;
1479
1484
performAllBatches ( ) ;
1480
1485
} ) ;
1481
1486
1482
- // Cells 1-4 should remain rendered after scrolling to the bottom of the list
1487
+ // Cell 10, and `initialNumToRender` / 2 cells on each side, should remain
1488
+ // rendered
1483
1489
expect ( component ) . toMatchSnapshot ( ) ;
1484
1490
1485
1491
ReactTestRenderer . act ( ( ) => {
1486
- component . getInstance ( ) . _onCellFocusCapture ( 17 ) ;
1492
+ component . getInstance ( ) . _onCellFocusCapture ( 37 ) ;
1487
1493
} ) ;
1488
1494
1489
- // Cells 2-4 should no longer be rendered after focus is moved to the end of
1490
- // the list
1495
+ // Cells around 10 should no longer be rendered after focus is moved to the
1496
+ // end of the list
1491
1497
expect ( component ) . toMatchSnapshot ( ) ;
1492
1498
1493
1499
ReactTestRenderer . act ( ( ) => {
1494
1500
simulateScroll ( component , { x : 0 , y : 0 } ) ;
1495
1501
performAllBatches ( ) ;
1496
1502
} ) ;
1497
1503
1498
- // Cells 16-18 should remain rendered after scrolling back to the top of the
1499
- // list
1504
+ // Cell 37, and `initialNumToRender` / 2 cells on each side, should remain
1505
+ // rendered
1500
1506
expect ( component ) . toMatchSnapshot ( ) ;
1501
1507
} ) ;
1502
1508
0 commit comments