Skip to content

Commit

Permalink
Nested virtualized lists should receive recordInteration events
Browse files Browse the repository at this point in the history
Summary:
Right now when an interaction is recorded on a parent VirtualizedList, the interaction isn't passed on to its children. That means that if `waitForInteraction` is set to true for a child list's viewability helper, it will never trigger a VPV.

This change adds forwarding of these events inside `onBeginScrollDrag`. It also forwards the interaction state of the parent list at register time, in case a child list is rendered mid-scroll.

Reviewed By: sahrens

Differential Revision: D6822091

fbshipit-source-id: dfe300e42722d4285f65787ab2c1368f050c5577
  • Loading branch information
logandaniels authored and facebook-github-bot committed Jan 29, 2018
1 parent ecaca80 commit ae2d5b1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Libraries/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ class VirtualizedList extends React.PureComponent<Props, State> {
}

recordInteraction() {
this._nestedChildLists.forEach(childList => {
childList.ref && childList.ref.recordInteraction();
});
this._viewabilityTuples.forEach(t => {
t.viewabilityHelper.recordInteraction();
});
Expand Down Expand Up @@ -512,6 +515,10 @@ class VirtualizedList extends React.PureComponent<Props, State> {
state: null,
});

if (this._hasInteracted) {
childList.ref.recordInteraction();
}

return existingChildData && existingChildData.state;
};

Expand Down Expand Up @@ -941,6 +948,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
_frames = {};
_footerLength = 0;
_hasDataChangedSinceEndReached = true;
_hasInteracted = false;
_hasMore = false;
_hasWarned = {};
_highestMeasuredFrameIndex = 0;
Expand Down Expand Up @@ -1334,9 +1342,13 @@ class VirtualizedList extends React.PureComponent<Props, State> {
}

_onScrollBeginDrag = (e): void => {
this._nestedChildLists.forEach(childList => {
childList.ref && childList.ref._onScrollBeginDrag(e);
});
this._viewabilityTuples.forEach(tuple => {
tuple.viewabilityHelper.recordInteraction();
});
this._hasInteracted = true;
this.props.onScrollBeginDrag && this.props.onScrollBeginDrag(e);
};

Expand Down

0 comments on commit ae2d5b1

Please sign in to comment.