Skip to content

Commit

Permalink
Move Logic to virtualized list
Browse files Browse the repository at this point in the history
  • Loading branch information
fabOnReact committed Mar 13, 2022
1 parent ce18d88 commit f49caa4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
14 changes: 1 addition & 13 deletions Libraries/Lists/FlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -656,18 +656,6 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
};
};

_getAccessibilityCollection = () => {
const accessibilityCollectionProps = {
itemCount: this.props.data ? this.props.data.length : 0,
//$FlowFixMe[incompatible-call] see https://bit.ly/3MJiZLL
rowCount: this._getItemCount(this.props.data),
columnCount: numColumnsOrDefault(this.props.numColumns),
hierarchical: false,
};

return accessibilityCollectionProps;
};

render(): React.Node {
const {
numColumns,
Expand All @@ -682,7 +670,7 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
getItem={this._getItem}
getItemCount={this._getItemCount}
keyExtractor={this._keyExtractor}
accessibilityCollection={this._getAccessibilityCollection()}
numColumns={numColumnsOrDefault(this.props.numColumns)}
accessibilityRole={Platform.select({
android:
numColumnsOrDefault(this.props.numColumns) > 1 ? 'grid' : 'list',
Expand Down
12 changes: 12 additions & 0 deletions Libraries/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,17 @@ class VirtualizedList extends React.PureComponent<Props, State> {
);
}

_getAccessibilityCollection = () => {
const accessibilityCollectionProps = {
itemCount: this.props.data ? this.props.data.length : 0,
rowCount: this.props.getItemCount(this.props.data),
columnCount: this.props.numColumns,
hierarchical: false,
};

return accessibilityCollectionProps;
};

_defaultRenderScrollComponent = props => {
const onRefresh = props.onRefresh;
if (this._isNestedWithSameOrientation()) {
Expand All @@ -1249,6 +1260,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
// $FlowFixMe[prop-missing] Invalid prop usage
<ScrollView
{...props}
accessibilityCollection={this._getAccessibilityCollection()}
refreshControl={
props.refreshControl == null ? (
<RefreshControl
Expand Down

0 comments on commit f49caa4

Please sign in to comment.