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

fix(fabric, lists): disable view flattening in VirtualizedList #2292

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ exports[`FlatList renders all the bells and whistles 1`] = `
</View>
</View>
<View
collapsable={true}
onLayout={[Function]}
>
<footer />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ exports[`SectionList renders all the bells and whistles 1`] = `
/>
</View>
<View
collapsable={true}
onLayout={[Function]}
>
<footer
Expand Down
4 changes: 4 additions & 0 deletions packages/virtualized-lists/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -989,8 +989,10 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
<ListEmptyComponent />
)): any);
cells.push(
// $FlowFixMe[prop-missing] React.Element internal inspection
<VirtualizedListCellContextProvider
cellKey={this._getCellKey() + '-empty'}
collapsable={Platform.OS !== 'macos'} // [macOS]
key="$empty">
{React.cloneElement(element, {
onLayout: (event: LayoutEvent) => {
Expand Down Expand Up @@ -1050,6 +1052,7 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
lastMetrics.offset + lastMetrics.length - firstMetrics.offset;
cells.push(
<View
collapsable={Platform.OS !== 'macos'} // [macOS]
key={`$spacer-${section.first}`}
style={{[spacerKey]: spacerSize}}
/>,
Expand Down Expand Up @@ -1090,6 +1093,7 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
cellKey={this._getFooterCellKey()}
key="$footer">
<View
collapsable={Platform.OS !== 'macos'} // [macOS]
onLayout={this._onLayoutFooter}
style={StyleSheet.compose(
inversionStyle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import type {
import {VirtualizedListCellContextProvider} from './VirtualizedListContext.js';
import invariant from 'invariant';
import * as React from 'react';
import {StyleSheet, View} from 'react-native';
import {Platform, StyleSheet, View} from 'react-native'; // [macOS]

export type Props<ItemT> = {
CellRendererComponent?: ?React.ComponentType<CellRendererProps<ItemT>>,
Expand Down Expand Up @@ -219,7 +219,7 @@ export default class CellRenderer<ItemT> extends React.PureComponent<
: horizontal
? [styles.row, inversionStyle]
: inversionStyle;
const result = !CellRendererComponent ? (
let result = !CellRendererComponent ? ( // [macOS]
<View
style={cellStyle}
onFocusCapture={this._onCellFocusCapture}
Expand All @@ -240,6 +240,11 @@ export default class CellRenderer<ItemT> extends React.PureComponent<
</CellRendererComponent>
);

if (Platform.OS === 'macos') {
// [macOS
result = React.cloneElement(result, {collapsable: false});
} // macOS]

return (
<VirtualizedListCellContextProvider cellKey={this.props.cellKey}>
{result}
Expand Down
Loading
Loading