Fixes regression of prop parsing for elevation (#38959)

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

When refactoring ViewProps in D47492635, `elevation` prop parsing was dropped. This restores it.

## Changelog:
[General] [Fixed] - Fabric regression for elevation prop in Android

Reviewed By: sammy-SC, mdvacca

Differential Revision: D48269510

fbshipit-source-id: 91867a6689857d0f07cf464ea6e5d6e7cee1af54
This commit is contained in:
Eric Rozell
2023-08-11 12:44:05 -07:00
committed by Facebook GitHub Bot
parent 7cd69962d0
commit 68c7cfe62d
4 changed files with 16 additions and 2 deletions
@@ -72,8 +72,6 @@ class BaseViewProps : public YogaStylableProps, public AccessibilityProps {
LayoutConformance experimental_layoutConformance{};
Float elevation{}; /* Android-only */
#pragma mark - Convenience Methods
BorderMetrics resolveBorderMetrics(LayoutMetrics const &layoutMetrics) const;
@@ -23,6 +23,14 @@ HostPlatformViewProps::HostPlatformViewProps(
RawProps const &rawProps,
bool shouldSetRawProps)
: BaseViewProps(context, sourceProps, rawProps, shouldSetRawProps),
elevation(
CoreFeatures::enablePropIteratorSetter ? sourceProps.elevation
: convertRawProp(
context,
rawProps,
"elevation",
sourceProps.elevation,
{})),
nativeBackground(
CoreFeatures::enablePropIteratorSetter
? sourceProps.nativeBackground
@@ -40,6 +40,8 @@ class HostPlatformViewProps : public BaseViewProps {
#pragma mark - Props
Float elevation{};
std::optional<NativeDrawable> nativeBackground{};
std::optional<NativeDrawable> nativeForeground{};
@@ -164,9 +164,11 @@ static inline ShadowNode::Unshared messWithLayoutableOnlyFlag(
: Transform::Perspective(42);
}
#ifdef ANDROID
if (entropy.random<bool>(0.1)) {
viewProps.elevation = entropy.random<bool>() ? 1 : 0;
}
#endif
return shadowNode.clone({newProps});
}
@@ -195,7 +197,9 @@ static inline ShadowNode::Unshared messWithNodeFlattenednessFlags(
viewProps.zIndex = {};
viewProps.pointerEvents = PointerEventsMode::Auto;
viewProps.transform = Transform::Identity();
#ifdef ANDROID
viewProps.elevation = 0;
#endif
} else {
viewProps.nativeId = "42";
viewProps.backgroundColor = whiteColor();
@@ -204,7 +208,9 @@ static inline ShadowNode::Unshared messWithNodeFlattenednessFlags(
viewProps.zIndex = {entropy.random<int>()};
viewProps.pointerEvents = PointerEventsMode::None;
viewProps.transform = Transform::Perspective(entropy.random<int>());
#ifdef ANDROID
viewProps.elevation = entropy.random<int>();
#endif
}
return shadowNode.clone({newProps});