From 24f9379e895755cefbe48bf4ea8a44d0f8c6b1b7 Mon Sep 17 00:00:00 2001 From: Nick Lefever Date: Tue, 31 Oct 2023 10:51:00 -0700 Subject: [PATCH 1/2] [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 --- .../Lists/VirtualizedListCellRenderer.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/virtualized-lists/Lists/VirtualizedListCellRenderer.js b/packages/virtualized-lists/Lists/VirtualizedListCellRenderer.js index ce5341107ffe23..24574fc9c65416 100644 --- a/packages/virtualized-lists/Lists/VirtualizedListCellRenderer.js +++ b/packages/virtualized-lists/Lists/VirtualizedListCellRenderer.js @@ -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 = { CellRendererComponent?: ?React.ComponentType>, @@ -219,7 +219,7 @@ export default class CellRenderer extends React.PureComponent< : horizontal ? [styles.row, inversionStyle] : inversionStyle; - const result = !CellRendererComponent ? ( + let result = !CellRendererComponent ? ( // [macOS] extends React.PureComponent< ); + if (Platform.OS === 'macos') { + // [macOS + result = React.cloneElement(result, {collapsable: false}); + } // macOS] + return ( {result} From 2649005d3ecd503404a344489fc1b53d7d1e9f1a Mon Sep 17 00:00:00 2001 From: Nick Lefever Date: Fri, 10 Nov 2023 01:18:12 +0100 Subject: [PATCH 2/2] [fabric] Disable view flattening in header/footer/empty/spacer components of VirtualizedList Summary: View flattening was already disabled in the cell renderer used by the Virtualized List in this diff D50846483 This diff disables view flattening in the header, footer, empty and spacer cells to fix the layout being broken because of the vertical axis flipping used by the reverse order virtualized list. Test Plan: Run Zeratul with Fabric enabled and scroll to the top of a message thread to show the participants summary header. | Before | After | |--| | {F1145726580} | {F1145726618} | Reviewers: shawndempsey, chpurrer, #rn-desktop Reviewed By: chpurrer Differential Revision: https://phabricator.intern.facebook.com/D51182545 Tasks: T167539420 --- .../__snapshots__/FlatList-test.js.snap | 1 + .../__snapshots__/SectionList-test.js.snap | 1 + .../Lists/VirtualizedList.js | 4 ++ .../VirtualizedList-test.js.snap | 43 +++++++++++++++++++ .../VirtualizedSectionList-test.js.snap | 2 + 5 files changed, 51 insertions(+) diff --git a/packages/react-native/Libraries/Lists/__tests__/__snapshots__/FlatList-test.js.snap b/packages/react-native/Libraries/Lists/__tests__/__snapshots__/FlatList-test.js.snap index 08b9739d54cc79..4912d50a2cc240 100644 --- a/packages/react-native/Libraries/Lists/__tests__/__snapshots__/FlatList-test.js.snap +++ b/packages/react-native/Libraries/Lists/__tests__/__snapshots__/FlatList-test.js.snap @@ -176,6 +176,7 @@ exports[`FlatList renders all the bells and whistles 1`] = `