@@ -315,7 +315,6 @@ let _keylessItemComponentName: string = '';
315
315
type State = {
316
316
renderMask : CellRenderMask ,
317
317
cellsAroundViewport : { first : number , last : number } ,
318
- lastFocusedItem : ?number ,
319
318
} ;
320
319
321
320
/**
@@ -739,7 +738,6 @@ class VirtualizedList extends React.PureComponent<Props, State> {
739
738
let initialState : State = {
740
739
cellsAroundViewport : initialRenderRegion ,
741
740
renderMask : VirtualizedList . _createRenderMask ( props , initialRenderRegion ) ,
742
- lastFocusedItem : null ,
743
741
} ;
744
742
745
743
if ( this . _isNestedWithSameOrientation ( ) ) {
@@ -972,7 +970,6 @@ class VirtualizedList extends React.PureComponent<Props, State> {
972
970
return {
973
971
cellsAroundViewport : prevState . cellsAroundViewport ,
974
972
renderMask : VirtualizedList . _createRenderMask ( newProps , constrainedCells ) ,
975
- lastFocusedItem : prevState . lastFocusedItem ,
976
973
} ;
977
974
}
978
975
@@ -1377,6 +1374,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1377
1374
_hiPriInProgress: boolean = false; // flag to prevent infinite hiPri cell limit update
1378
1375
_highestMeasuredFrameIndex = 0;
1379
1376
_indicesToKeys: Map< number , string > = new Map();
1377
+ _lastFocusedItem: ?number = null;
1380
1378
_nestedChildLists: Map<
1381
1379
string ,
1382
1380
{
@@ -1486,12 +1484,16 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1486
1484
}
1487
1485
1488
1486
_onCellFocusCapture ( itemIndex : number ) {
1487
+ this . _lastFocusedItem = itemIndex ;
1489
1488
const renderMask = VirtualizedList . _createRenderMask (
1490
1489
this . props ,
1491
1490
this . state . cellsAroundViewport ,
1492
- itemIndex ,
1491
+ this . _lastFocusedItem ,
1493
1492
) ;
1494
- this . setState ( { ...this . state , renderMask, lastFocusedItem : itemIndex } ) ;
1493
+
1494
+ if ( ! renderMask . equals ( this . state . renderMask ) ) {
1495
+ this . setState ( { ...this . state , renderMask} ) ;
1496
+ }
1495
1497
}
1496
1498
1497
1499
_onCellUnmount = ( cellKey : string ) => {
@@ -1922,7 +1924,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1922
1924
const renderMask = VirtualizedList . _createRenderMask (
1923
1925
props ,
1924
1926
cellsAroundViewport ,
1925
- state . lastFocusedItem ,
1927
+ this . _lastFocusedItem ,
1926
1928
) ;
1927
1929
1928
1930
if (
0 commit comments