From ae2d5b1e68a2207c27ef2f1b533f86c86d6d849b Mon Sep 17 00:00:00 2001 From: Logan Daniels Date: Mon, 29 Jan 2018 11:46:53 -0800 Subject: [PATCH] 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 --- Libraries/Lists/VirtualizedList.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index 6a1399e63..0065fdecc 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -375,6 +375,9 @@ class VirtualizedList extends React.PureComponent { } recordInteraction() { + this._nestedChildLists.forEach(childList => { + childList.ref && childList.ref.recordInteraction(); + }); this._viewabilityTuples.forEach(t => { t.viewabilityHelper.recordInteraction(); }); @@ -512,6 +515,10 @@ class VirtualizedList extends React.PureComponent { state: null, }); + if (this._hasInteracted) { + childList.ref.recordInteraction(); + } + return existingChildData && existingChildData.state; }; @@ -941,6 +948,7 @@ class VirtualizedList extends React.PureComponent { _frames = {}; _footerLength = 0; _hasDataChangedSinceEndReached = true; + _hasInteracted = false; _hasMore = false; _hasWarned = {}; _highestMeasuredFrameIndex = 0; @@ -1334,9 +1342,13 @@ class VirtualizedList extends React.PureComponent { } _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); };