diff --git a/packages/react-native/Libraries/Components/ScrollView/__tests__/ScrollView-viewCulling-itest.js b/packages/react-native/Libraries/Components/ScrollView/__tests__/ScrollView-viewCulling-itest.js index b0daeb7ec4d..50efd299442 100644 --- a/packages/react-native/Libraries/Components/ScrollView/__tests__/ScrollView-viewCulling-itest.js +++ b/packages/react-native/Libraries/Components/ScrollView/__tests__/ScrollView-viewCulling-itest.js @@ -14,6 +14,7 @@ import '../../../Core/InitializeCore.js'; import ensureInstance from '../../../../src/private/utilities/ensureInstance'; import ReactNativeElement from '../../../../src/private/webapis/dom/nodes/ReactNativeElement'; +import Modal from '../../../Modal/Modal'; import View from '../../View/View'; import ScrollView from '../ScrollView'; import Fantom from '@react-native/fantom'; @@ -949,3 +950,69 @@ test('view flattening with culling', () => { 'Insert {type: "View", parentNativeID: (N/A), index: 0, nativeID: "child"}', ]); }); + +test('culling inside of Modal', () => { + const root = Fantom.createRoot({viewportWidth: 100, viewportHeight: 100}); + let maybeNode; + + Fantom.runTask(() => { + root.render( + // is scrolled down and if it wasn't for the Modal, + // the content would be culled. + + ) => { + maybeNode = node; + }} + /> + , + ); + }); + + const element = ensureInstance(maybeNode, ReactNativeElement); + + Fantom.runOnUIThread(() => { + Fantom.enqueueModalSizeUpdate(element, { + width: 100, + height: 100, + }); + }); + Fantom.runWorkLoop(); + + expect(root.takeMountingManagerLogs()).toEqual([ + 'Update {type: "RootView", nativeID: (root)}', + 'Create {type: "ScrollView", nativeID: (N/A)}', + 'Insert {type: "ScrollView", parentNativeID: (root), index: 0, nativeID: (N/A)}', + 'Create {type: "View", nativeID: (N/A)}', + 'Create {type: "ModalHostView", nativeID: (root)}', + 'Create {type: "View", nativeID: (N/A)}', + 'Insert {type: "View", parentNativeID: (root), index: 0, nativeID: (N/A)}', + 'Insert {type: "ModalHostView", parentNativeID: (N/A), index: 0, nativeID: (root)}', + 'Insert {type: "View", parentNativeID: (N/A), index: 0, nativeID: (N/A)}', + ]); + + Fantom.runTask(() => { + root.render( + + ) => { + maybeNode = node; + }}> + + + , + ); + }); + + expect(root.takeMountingManagerLogs()).toEqual([ + 'Create {type: "View", nativeID: "child"}', + 'Insert {type: "View", parentNativeID: (N/A), index: 0, nativeID: "child"}', + ]); +});