Skip to content

Commit bfbc280

Browse files
author
Alex Akers
committed
[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.
1 parent c66b1c6 commit bfbc280

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Libraries/Components/ScrollView/ScrollView.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ var PointPropType = require('PointPropType');
1717
var RCTScrollView = require('NativeModules').UIManager.RCTScrollView;
1818
var RCTScrollViewConsts = RCTScrollView.Constants;
1919
var React = require('React');
20+
var ReactChildren = require('ReactChildren');
2021
var ReactNativeViewAttributes = require('ReactNativeViewAttributes');
2122
var RCTUIManager = require('NativeModules').UIManager;
2223
var ScrollResponder = require('ScrollResponder');
@@ -277,13 +278,24 @@ var ScrollView = React.createClass({
277278
}
278279
}
279280

281+
var children = this.props.children;
282+
if (this.props.stickyHeaderIndices) {
283+
children = ReactChildren.map(children, (child) => {
284+
if (child) {
285+
return <View collapsible={false}>{child}</View>;
286+
} else {
287+
return child;
288+
}
289+
});
290+
}
291+
280292
var contentContainer =
281293
<View
282294
collapsible={false}
283295
ref={INNERVIEW}
284296
style={contentContainerStyle}
285297
removeClippedSubviews={this.props.removeClippedSubviews}>
286-
{this.props.children}
298+
{children}
287299
</View>;
288300

289301
var alwaysBounceHorizontal =

0 commit comments

Comments
 (0)