Skip to content

Commit

Permalink
Merge pull request #6798 from azimgd/flatlist-stick-to-bottom
Browse files Browse the repository at this point in the history
Fix inverted flatlist at ReportActionsView with few items should stick to bottom of page

(cherry picked from commit 11a708c)
  • Loading branch information
Julesssss authored and OSBotify committed Dec 16, 2021
1 parent c4f0168 commit 31702e2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/components/InvertedFlatList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@ import React, {
forwardRef,
} from 'react';
import PropTypes from 'prop-types';
import {FlatList} from 'react-native';
import {FlatList, StyleSheet} from 'react-native';
import _ from 'underscore';
import BaseInvertedFlatList from './BaseInvertedFlatList';
import styles from '../../styles/styles';

const propTypes = {
/** Passed via forwardRef so we can access the FlatList ref */
innerRef: PropTypes.shape({
current: PropTypes.instanceOf(FlatList),
}).isRequired,

/** Any additional styles to apply */
// eslint-disable-next-line react/forbid-prop-types
contentContainerStyle: PropTypes.any,
};

// This is adapted from https://codesandbox.io/s/react-native-dsyse
Expand Down Expand Up @@ -61,12 +66,16 @@ class InvertedFlatList extends React.Component {
{...this.props}
ref={el => this.list = el}
shouldMeasureItems
contentContainerStyle={StyleSheet.compose(this.props.contentContainerStyle, styles.justifyContentEnd)}
/>
);
}
}

InvertedFlatList.propTypes = propTypes;
InvertedFlatList.defaultProps = {
contentContainerStyle: {},
};

export default forwardRef((props, ref) => (
// eslint-disable-next-line react/jsx-props-no-spreading
Expand Down
5 changes: 4 additions & 1 deletion src/pages/home/report/ReportActionsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,10 @@ class ReportActionsView extends React.Component {
data={this.sortedReportActions}
renderItem={this.renderItem}
CellRendererComponent={this.renderCell}
contentContainerStyle={[styles.chatContentScrollView, shouldShowReportRecipientLocalTime && styles.pt0]}
contentContainerStyle={[
styles.chatContentScrollView,
shouldShowReportRecipientLocalTime && styles.pt0,
]}
keyExtractor={this.keyExtractor}
initialRowHeight={32}
initialNumToRender={this.calculateInitialNumToRender()}
Expand Down
2 changes: 1 addition & 1 deletion src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ const styles = {

chatContentScrollView: {
flexGrow: 1,
justifyContent: 'flex-end',
justifyContent: 'flex-start',
paddingVertical: 16,
},

Expand Down

0 comments on commit 31702e2

Please sign in to comment.