mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fabric: Enable zIndex only for non-static positioned views
Summary: The standard says that zIndex should only be defined for non-`static` positioned views. This diff implements it. For now, it actually enables zIndex for all views in RN because there is no way to specify `position: static` but will will give that ability by changing Flow definitions in future diffs in a couple of weeks (to ensure OTA safety). Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D22098586 fbshipit-source-id: 77dacbee0fe887f667ba81640b8bd759e1df11fd
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ca6700f3c3
commit
476ab7481e
@@ -105,13 +105,18 @@ class ConcreteViewShadowNode : public ConcreteShadowNode<
|
||||
void initialize() noexcept {
|
||||
auto &props = BaseShadowNode::getConcreteProps();
|
||||
|
||||
BaseShadowNode::orderIndex_ = props.zIndex.value_or(0);
|
||||
|
||||
if (props.yogaStyle.display() == YGDisplayNone) {
|
||||
BaseShadowNode::traits_.set(ShadowNodeTraits::Trait::Hidden);
|
||||
} else {
|
||||
BaseShadowNode::traits_.unset(ShadowNodeTraits::Trait::Hidden);
|
||||
}
|
||||
|
||||
// `zIndex` is only defined for non-`static` positioned views.
|
||||
if (props.yogaStyle.positionType() != YGPositionTypeStatic) {
|
||||
BaseShadowNode::orderIndex_ = props.zIndex.value_or(0);
|
||||
} else {
|
||||
BaseShadowNode::orderIndex_ = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ void ViewShadowNode::initialize() noexcept {
|
||||
viewProps.opacity != 1.0 || viewProps.transform != Transform{} ||
|
||||
viewProps.elevation != 0 ||
|
||||
(viewProps.zIndex.has_value() &&
|
||||
viewProps.yogaStyle.positionType() == YGPositionTypeAbsolute) ||
|
||||
viewProps.yogaStyle.positionType() != YGPositionTypeStatic) ||
|
||||
viewProps.yogaStyle.display() == YGDisplayNone ||
|
||||
viewProps.getClipsContentToBounds() ||
|
||||
isColorMeaningful(viewProps.shadowColor) ||
|
||||
|
||||
Reference in New Issue
Block a user