From bfbc280fb441ad76680b6f6ac00d840d10e5d831 Mon Sep 17 00:00:00 2001 From: Alex Akers Date: Wed, 8 Jul 2015 09:28:28 -0700 Subject: [PATCH] [React Native] Fix scroll view sticky headers Summary: The `ScrollView` component tells the native side the subview indices of the views to make sticky. The problem is that, once layout-only views are collapsed, the indices are no longer reflective of the original views to make stick to the top. --- Libraries/Components/ScrollView/ScrollView.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index f01cce58a..2625c20b7 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -17,6 +17,7 @@ var PointPropType = require('PointPropType'); var RCTScrollView = require('NativeModules').UIManager.RCTScrollView; var RCTScrollViewConsts = RCTScrollView.Constants; var React = require('React'); +var ReactChildren = require('ReactChildren'); var ReactNativeViewAttributes = require('ReactNativeViewAttributes'); var RCTUIManager = require('NativeModules').UIManager; var ScrollResponder = require('ScrollResponder'); @@ -277,13 +278,24 @@ var ScrollView = React.createClass({ } } + var children = this.props.children; + if (this.props.stickyHeaderIndices) { + children = ReactChildren.map(children, (child) => { + if (child) { + return {child}; + } else { + return child; + } + }); + } + var contentContainer = - {this.props.children} + {children} ; var alwaysBounceHorizontal =