Skip to content

Commit d546971

Browse files
Nick LefeverSaadnajmi
Nick Lefever
authored andcommitted
[fabric] Disable view flattening in VirtualizedList cells
Summary: Scroll views set up with an inverted vertical axis can't support view flattening due to the flattening not taking the axis inversion in consideration while repositioning the views. This diff disables view flattening on the cells of the virtualized list so that the layout would be correct in inverted scroll views when using Fabric. The change is not being applied to ScrollView directly because we can safely assume that vertical axis inversion will only be enabled on VirtualizedList/FlatList. Test Plan: Run Zeratul with Fabric and check that the vertical order of grouped bubble messages is correct. | Before | After | |--| | {F1136386200} | {F1136386364} | Reviewers: shawndempsey, #rn-desktop Reviewed By: shawndempsey Differential Revision: https://phabricator.intern.facebook.com/D50846483 Tasks: T167539420
1 parent bf133b9 commit d546971

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/virtualized-lists/Lists/VirtualizedListCellRenderer.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import type {
1919
import {VirtualizedListCellContextProvider} from './VirtualizedListContext.js';
2020
import invariant from 'invariant';
2121
import * as React from 'react';
22-
import {StyleSheet, View} from 'react-native';
22+
import {Platform, StyleSheet, View} from 'react-native'; // [macOS]
2323

2424
export type Props<ItemT> = {
2525
CellRendererComponent?: ?React.ComponentType<CellRendererProps<ItemT>>,
@@ -219,7 +219,7 @@ export default class CellRenderer<ItemT> extends React.PureComponent<
219219
: horizontal
220220
? [styles.row, inversionStyle]
221221
: inversionStyle;
222-
const result = !CellRendererComponent ? (
222+
let result = !CellRendererComponent ? ( // [macOS]
223223
<View
224224
style={cellStyle}
225225
onFocusCapture={this._onCellFocusCapture}
@@ -240,6 +240,11 @@ export default class CellRenderer<ItemT> extends React.PureComponent<
240240
</CellRendererComponent>
241241
);
242242

243+
if (Platform.OS === 'macos') {
244+
// [macOS
245+
result = React.cloneElement(result, {collapsable: false});
246+
} // macOS]
247+
243248
return (
244249
<VirtualizedListCellContextProvider cellKey={this.props.cellKey}>
245250
{result}

0 commit comments

Comments
 (0)