Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invert list manually on android #12820

Merged
merged 9 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/components/InvertedFlatList/BaseInvertedFlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ class BaseInvertedFlatList extends Component {
// eslint-disable-next-line react/jsx-props-no-spreading
{...this.props}
ref={this.props.innerRef}
inverted
renderItem={this.renderItem}
sizeMap={this.sizeMap}

Expand Down
24 changes: 24 additions & 0 deletions src/components/InvertedFlatList/index.android.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React, {forwardRef} from 'react';
import {View} from 'react-native';
import BaseInvertedFlatList from './BaseInvertedFlatList';
import styles from '../../styles/styles';

const InvertedCell = props => (
// eslint-disable-next-line react/jsx-props-no-spreading
<View {...props} style={styles.invert} />
);

export default forwardRef((props, ref) => (
<BaseInvertedFlatList
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
ref={ref}

// Manually invert the FlatList to circumvent a react-native bug that causes ANR (application not responding) on android 13
inverted={false}
style={styles.invert}
verticalScrollbarPosition="left" // We are mirroring the X and Y axis, so we need to swap the scrollbar position

CellRendererComponent={InvertedCell}
/>
));
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ export default forwardRef((props, ref) => (
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
ref={ref}
inverted
/>
));
1 change: 1 addition & 0 deletions src/components/InvertedFlatList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class InvertedFlatList extends React.Component {
<BaseInvertedFlatList
// eslint-disable-next-line react/jsx-props-no-spreading
{...this.props}
inverted
ref={el => this.list = el}
shouldMeasureItems
contentContainerStyle={StyleSheet.compose(this.props.contentContainerStyle, styles.justifyContentEnd)}
Expand Down
5 changes: 5 additions & 0 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -2633,6 +2633,11 @@ const styles = {
transform: [{scale: 0}],
},

invert: {
// It's important to invert the Y AND X axis to prevent a react native issue that can lead to ANRs on android 13
transform: [{scaleX: -1}, {scaleY: -1}],
},

keyboardShortcutModalContainer: {
maxHeight: '100%',
flex: '0 0 auto',
Expand Down