Skip to content

Commit 11a708c

Browse files
authored
Merge pull request #6798 from azimgd/flatlist-stick-to-bottom
Fix inverted flatlist at ReportActionsView with few items should stick to bottom of page
2 parents aac3f04 + adb0d8a commit 11a708c

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/components/InvertedFlatList/index.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@ import React, {
22
forwardRef,
33
} from 'react';
44
import PropTypes from 'prop-types';
5-
import {FlatList} from 'react-native';
5+
import {FlatList, StyleSheet} from 'react-native';
66
import _ from 'underscore';
77
import BaseInvertedFlatList from './BaseInvertedFlatList';
8+
import styles from '../../styles/styles';
89

910
const propTypes = {
1011
/** Passed via forwardRef so we can access the FlatList ref */
1112
innerRef: PropTypes.shape({
1213
current: PropTypes.instanceOf(FlatList),
1314
}).isRequired,
15+
16+
/** Any additional styles to apply */
17+
// eslint-disable-next-line react/forbid-prop-types
18+
contentContainerStyle: PropTypes.any,
1419
};
1520

1621
// This is adapted from https://codesandbox.io/s/react-native-dsyse
@@ -61,12 +66,16 @@ class InvertedFlatList extends React.Component {
6166
{...this.props}
6267
ref={el => this.list = el}
6368
shouldMeasureItems
69+
contentContainerStyle={StyleSheet.compose(this.props.contentContainerStyle, styles.justifyContentEnd)}
6470
/>
6571
);
6672
}
6773
}
6874

6975
InvertedFlatList.propTypes = propTypes;
76+
InvertedFlatList.defaultProps = {
77+
contentContainerStyle: {},
78+
};
7079

7180
export default forwardRef((props, ref) => (
7281
// eslint-disable-next-line react/jsx-props-no-spreading

src/pages/home/report/ReportActionsView.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,10 @@ class ReportActionsView extends React.Component {
562562
data={this.sortedReportActions}
563563
renderItem={this.renderItem}
564564
CellRendererComponent={this.renderCell}
565-
contentContainerStyle={[styles.chatContentScrollView, shouldShowReportRecipientLocalTime && styles.pt0]}
565+
contentContainerStyle={[
566+
styles.chatContentScrollView,
567+
shouldShowReportRecipientLocalTime && styles.pt0,
568+
]}
566569
keyExtractor={this.keyExtractor}
567570
initialRowHeight={32}
568571
initialNumToRender={this.calculateInitialNumToRender()}

src/styles/styles.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ const styles = {
11611161

11621162
chatContentScrollView: {
11631163
flexGrow: 1,
1164-
justifyContent: 'flex-end',
1164+
justifyContent: 'flex-start',
11651165
paddingVertical: 16,
11661166
},
11671167

0 commit comments

Comments
 (0)