Skip to content

Commit 9f07b9a

Browse files
committed
[ListView] Operate on the true scroll responder instead of the scroll component
Summary: When composing scroll views, `this.refs[SCROLLVIEW_REF]` may refer to another higher-order scroll component instead of a ScrollView. This can cause issues if you expect to need it to be a ScrollView backed by an RCTScrollView. The solution is to call `getScrollResponder()` - as long as all higher-order scroll components implement this method, it will make its way down to the true ScrollView, which is what ListView wants here. Closes #1927 Github Author: James Ide <ide@jameside.com>
1 parent d5943b0 commit 9f07b9a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Libraries/CustomComponents/ListView/ListView.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ var ListView = React.createClass({
221221
* such as scrollTo.
222222
*/
223223
getScrollResponder: function() {
224-
return this.refs[SCROLLVIEW_REF];
224+
return this.refs[SCROLLVIEW_REF].getScrollResponder();
225225
},
226226

227227
setNativeProps: function(props) {
@@ -399,22 +399,23 @@ var ListView = React.createClass({
399399
*/
400400

401401
_measureAndUpdateScrollProps: function() {
402+
var scrollComponent = this.getScrollResponder();
402403
RCTUIManager.measureLayout(
403-
this.refs[SCROLLVIEW_REF].getInnerViewNode(),
404-
React.findNodeHandle(this.refs[SCROLLVIEW_REF]),
404+
scrollComponent.getInnerViewNode(),
405+
React.findNodeHandle(scrollComponent),
405406
logError,
406407
this._setScrollContentHeight
407408
);
408409
RCTUIManager.measureLayoutRelativeToParent(
409-
React.findNodeHandle(this.refs[SCROLLVIEW_REF]),
410+
React.findNodeHandle(scrollComponent),
410411
logError,
411412
this._setScrollVisibleHeight
412413
);
413414

414415
// RKScrollViewManager.calculateChildFrames not available on every platform
415416
RKScrollViewManager && RKScrollViewManager.calculateChildFrames &&
416417
RKScrollViewManager.calculateChildFrames(
417-
React.findNodeHandle(this.refs[SCROLLVIEW_REF]),
418+
React.findNodeHandle(scrollComponent),
418419
this._updateChildFrames,
419420
);
420421
},

0 commit comments

Comments
 (0)