diff --git a/packages/react-native/Libraries/Components/View/View.js b/packages/react-native/Libraries/Components/View/View.js index d9814254743..d54135af489 100644 --- a/packages/react-native/Libraries/Components/View/View.js +++ b/packages/react-native/Libraries/Components/View/View.js @@ -10,6 +10,7 @@ import type {ViewProps} from './ViewPropTypes'; +import ReactNativeFeatureFlags from '../../ReactNative/ReactNativeFeatureFlags'; import flattenStyle from '../../StyleSheet/flattenStyle'; import TextAncestor from '../../Text/TextAncestor'; import ViewNativeComponent from './ViewNativeComponent'; @@ -100,10 +101,20 @@ const View: React.AbstractComponent< let style = flattenStyle(otherProps.style); const newPointerEvents = style?.pointerEvents || pointerEvents; + const collapsableOverride = + ReactNativeFeatureFlags.shouldForceUnflattenForElevation() + ? { + collapsable: + style != null && style.elevation != null && style.elevation !== 0 + ? false + : otherProps.collapsable, + } + : {}; const actualView = ( boolean, + /** + * Enables a hotfix for forcing materialization of views with elevation set. + */ + shouldForceUnflattenForElevation: () => boolean, |}; const ReactNativeFeatureFlags: FeatureFlags = { @@ -70,6 +74,7 @@ const ReactNativeFeatureFlags: FeatureFlags = { shouldUseAnimatedObjectForTransform: () => false, shouldUseSetNativePropsInFabric: () => false, enableNativeViewConfigsInBridgelessMode: () => false, + shouldForceUnflattenForElevation: () => false, }; module.exports = ReactNativeFeatureFlags;