From a9c2ae7cb35424e109c4c017d634c9e1a314ea04 Mon Sep 17 00:00:00 2001 From: ptaylor Date: Sun, 27 Jan 2019 12:35:58 -0800 Subject: [PATCH] Guard against incomplete cell measurement --- source/Grid/utils/CellSizeAndPositionManager.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/Grid/utils/CellSizeAndPositionManager.js b/source/Grid/utils/CellSizeAndPositionManager.js index 1f37930d1..74a812b60 100644 --- a/source/Grid/utils/CellSizeAndPositionManager.js +++ b/source/Grid/utils/CellSizeAndPositionManager.js @@ -246,6 +246,13 @@ export default class CellSizeAndPositionManager { return nearestCellIndex; } nearestCellIndex = vector.indexOf(targetOffset); + // Guard in case `getSizeAndPositionOfCell` didn't fully measure to + // the nearestCellIndex. This might happen scrolling quickly down + // and back up on large lists -- possible race with React or DOM? + if (nearestCellIndex === -1) { + nearestCellIndex = this._lastMeasuredIndex; + this._lastMeasuredIndex = nearestCellIndex - 1; + } } return nearestCellIndex;