Make it so that a view with a filter forms a stacking context and containing block (#44456)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44456

Self explanatory: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_positioned_layout/Understanding_z-index/Stacking_context#description and https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D55044674

fbshipit-source-id: fcc3b04f5b1d5dd11b8e9e15b3c5bdbf9b609f7c
This commit is contained in:
Joe Vilches
2024-05-08 13:39:09 -07:00
committed by Facebook GitHub Bot
parent f340e6e575
commit d776d8c8a4
2 changed files with 6 additions and 2 deletions
@@ -61,6 +61,7 @@ void ViewShadowNode::initialize() noexcept {
viewProps.accessibilityViewIsModal ||
viewProps.importantForAccessibility != ImportantForAccessibility::Auto ||
viewProps.removeClippedSubviews || viewProps.cursor != Cursor::Auto ||
!viewProps.filter.empty() ||
HostPlatformViewTraitsInitializer::formsStackingContext(viewProps);
bool formsView = formsStackingContext ||
@@ -376,8 +376,11 @@ void YogaLayoutableShadowNode::updateYogaProps() {
yogaNode_.setStyle(styleResult);
if (getTraits().check(ShadowNodeTraits::ViewKind)) {
auto& viewProps = static_cast<const ViewProps&>(*props_);
YGNodeSetAlwaysFormsContainingBlock(
&yogaNode_, viewProps.transform != Transform::Identity());
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
bool alwaysFormsContainingBlock =
viewProps.transform != Transform::Identity() ||
!viewProps.filter.empty();
YGNodeSetAlwaysFormsContainingBlock(&yogaNode_, alwaysFormsContainingBlock);
}
}