mirror of
https://github.com/status-im/react-native.git
synced 2025-02-23 22:58:19 +00:00
Fix behaviour of Header, Footer and Empty List components in VirtualizedList when it's inverted (#24167)
Summary: Fixes https://github.com/facebook/react-native/issues/23453 Fixes https://github.com/facebook/react-native/issues/21196 Basically, changes made in https://github.com/facebook/react-native/pull/21496 currently breaks behavior of `<VirtualizedList />` and any components that are based on it (`<SectionList />, <FlatList />`). This PR solves both issues listed above. Visual confirmation of the resolved issue: **Vertical, not inverted, not empty**  **Vertical, not inverted, empty**  **Vertical, inverted, not empty**  **Vertical, inverted, empty**  **Horizontal, not inverted, not empty**  **Horizontal, not inverted, empty**  **Horizontal, inverted, not empty**  **Horizontal, inverted, empty**  [General] [Fixed] - Fixed VirtualizedList, SectionList and FlatList behavior on rendering list headers with inverted prop and zero items Pull Request resolved: https://github.com/facebook/react-native/pull/24167 Differential Revision: D14642345 Pulled By: cpojer fbshipit-source-id: b530bbbd57f60e53a976ac5db272ea4b2d2b3e99
This commit is contained in:
parent
13cb5a91ed
commit
e94d3444dc
@ -885,16 +885,17 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
<ListEmptyComponent />
|
||||
)): any);
|
||||
cells.push(
|
||||
React.cloneElement(element, {
|
||||
key: '$empty',
|
||||
onLayout: event => {
|
||||
this._onLayoutEmpty(event);
|
||||
if (element.props.onLayout) {
|
||||
element.props.onLayout(event);
|
||||
}
|
||||
},
|
||||
style: [element.props.style, inversionStyle],
|
||||
}),
|
||||
<View key="$empty" style={inversionStyle}>
|
||||
{React.cloneElement(element, {
|
||||
onLayout: event => {
|
||||
this._onLayoutEmpty(event);
|
||||
if (element.props.onLayout) {
|
||||
element.props.onLayout(event);
|
||||
}
|
||||
},
|
||||
style: element.props.style,
|
||||
})}
|
||||
</View>,
|
||||
);
|
||||
}
|
||||
if (ListFooterComponent) {
|
||||
@ -937,7 +938,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
: this.props.inverted,
|
||||
stickyHeaderIndices,
|
||||
};
|
||||
if (inversionStyle && itemCount !== 0) {
|
||||
if (inversionStyle) {
|
||||
/* $FlowFixMe(>=0.70.0 site=react_native_fb) This comment suppresses an
|
||||
* error found when Flow v0.70 was deployed. To see the error delete
|
||||
* this comment and run Flow. */
|
||||
|
@ -668,7 +668,11 @@ exports[`VirtualizedList renders empty list with empty component 1`] = `
|
||||
>
|
||||
<header />
|
||||
</View>
|
||||
<empty />
|
||||
<View
|
||||
style={null}
|
||||
>
|
||||
<empty />
|
||||
</View>
|
||||
<View
|
||||
onLayout={[Function]}
|
||||
>
|
||||
|
Loading…
x
Reference in New Issue
Block a user