Fixed incorrect rows reported in onChangeVisibleRows

Summary:
There is a bug in onChangeVisibleRows when the renderSeparator is not null. The _updateVisibleRows function does not account for the presence of separator frames in the  _childFrames array.

When renderSeparator is not null, increment the totalIndex an additional
time for each row that isn't the last in its section, or the last in the entire
list.

This continues a slightly brittle precedent of having a set of parallel conditions in render and _updateVisibleRows. (i.e. renderSectionHeader is used in both functions, in render as a condition to create a sectionHeader, and in _updateVisibleRows as a condition to increment the totalIndex.

Before change:
![yeeqnmvmif](https://cloud.githubusercontent.com/assets/9422359/14515342/38543952-01c7-11e6-984c-7c1a3fc3d820.gif)

After change:
![gzbrljclzm](https://cloud.githubusercontent.com/assets/9422359/14515340/3296e294-01c7-11e6-8ae9-1ad313600956.gif)

Built using https://gist.github.com/dmueller39/f95028f6fe8bd251944bb604e51f18b2
Closes https://github.com/facebook/react-native/pull/6965

Differential Revision: D3328001

Pulled By: vjeux

fbshipit-source-id: 977e54382ee07be7a432a54febafcae6acaae905
This commit is contained in:
dmueller39 2016-05-20 08:04:10 -07:00 committed by Facebook Github Bot 8
parent d6c2f5f3f1
commit 0aea74ebea
1 changed files with 4 additions and 0 deletions

View File

@ -596,6 +596,10 @@ var ListView = React.createClass({
var rowID = rowIDs[rowIdx];
var frame = this._childFrames[totalIndex];
totalIndex++;
if(this.props.renderSeparator &&
(rowIdx !== rowIDs.length - 1 || sectionIdx === allRowIDs.length - 1)){
totalIndex++;
}
if (!frame) {
break;
}