Skip to content

Commit ae2d5b1

Browse files
logandanielsfacebook-github-bot
authored andcommitted
Nested virtualized lists should receive recordInteration events
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
1 parent ecaca80 commit ae2d5b1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Libraries/Lists/VirtualizedList.js

+12
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,9 @@ class VirtualizedList extends React.PureComponent<Props, State> {
375375
}
376376

377377
recordInteraction() {
378+
this._nestedChildLists.forEach(childList => {
379+
childList.ref && childList.ref.recordInteraction();
380+
});
378381
this._viewabilityTuples.forEach(t => {
379382
t.viewabilityHelper.recordInteraction();
380383
});
@@ -512,6 +515,10 @@ class VirtualizedList extends React.PureComponent<Props, State> {
512515
state: null,
513516
});
514517

518+
if (this._hasInteracted) {
519+
childList.ref.recordInteraction();
520+
}
521+
515522
return existingChildData && existingChildData.state;
516523
};
517524

@@ -941,6 +948,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
941948
_frames = {};
942949
_footerLength = 0;
943950
_hasDataChangedSinceEndReached = true;
951+
_hasInteracted = false;
944952
_hasMore = false;
945953
_hasWarned = {};
946954
_highestMeasuredFrameIndex = 0;
@@ -1334,9 +1342,13 @@ class VirtualizedList extends React.PureComponent<Props, State> {
13341342
}
13351343

13361344
_onScrollBeginDrag = (e): void => {
1345+
this._nestedChildLists.forEach(childList => {
1346+
childList.ref && childList.ref._onScrollBeginDrag(e);
1347+
});
13371348
this._viewabilityTuples.forEach(tuple => {
13381349
tuple.viewabilityHelper.recordInteraction();
13391350
});
1351+
this._hasInteracted = true;
13401352
this.props.onScrollBeginDrag && this.props.onScrollBeginDrag(e);
13411353
};
13421354

0 commit comments

Comments
 (0)