Skip to content

Commit 05ed007

Browse files
joevilchesfacebook-github-bot
authored andcommitted
Set up gating for position: relative as default (#41711)
Summary: Pull Request resolved: #41711 We want the default position to be relative for a number of reasons. This should be fine for the most part but putting a killswitch around this change just in case things blow up. Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D51643446 fbshipit-source-id: 4f7d1e498eb663801ef6d88ba9cd9b64c781d66b
1 parent ee31ec9 commit 05ed007

File tree

6 files changed

+16
-1
lines changed

6 files changed

+16
-1
lines changed

packages/react-native/React/Fabric/RCTSurfacePresenter.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,10 @@ - (RCTScheduler *)_createScheduler
284284
CoreFeatures::enableClonelessStateProgression = true;
285285
}
286286

287+
if (reactNativeConfig && reactNativeConfig->getBool("react_fabric:position_relative_default")) {
288+
CoreFeatures::positionRelativeDefault = true;
289+
}
290+
287291
auto componentRegistryFactory =
288292
[factory = wrapManagedObject(_mountingManager.componentViewRegistry.componentViewFactory)](
289293
const EventDispatcher::Weak &eventDispatcher, const ContextContainer::Shared &contextContainer) {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,7 @@ public class ReactFeatureFlags {
182182
* when there is work to do.
183183
*/
184184
public static boolean enableOnDemandReactChoreographer = false;
185+
186+
/** When enabled, the default value of the position style property is relative. */
187+
public static boolean positionRelativeDefault = false;
185188
}

packages/react-native/ReactAndroid/src/main/jni/react/fabric/Binding.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,8 @@ void Binding::installFabricUIManager(
424424
getFeatureFlagValue("enableClonelessStateProgression");
425425
CoreFeatures::excludeYogaFromRawProps =
426426
getFeatureFlagValue("excludeYogaFromRawProps");
427+
CoreFeatures::positionRelativeDefault =
428+
getFeatureFlagValue("positionRelativeDefault");
427429

428430
// RemoveDelete mega-op
429431
ShadowViewMutation::PlatformSupportsRemoveDeleteTreeInstruction =

packages/react-native/ReactCommon/react/renderer/components/view/YogaStylableProps.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ YogaStylableProps::YogaStylableProps(
3838
/*static*/ const yoga::Style& YogaStylableProps::defaultStyle() {
3939
static const auto defaultStyle = []() {
4040
yoga::Style style;
41-
style.setPositionType(yoga::PositionType::Static);
41+
style.setPositionType(
42+
CoreFeatures::positionRelativeDefault ? yoga::PositionType::Relative
43+
: yoga::PositionType::Static);
4244
return style;
4345
}();
4446

packages/react-native/ReactCommon/react/utils/CoreFeatures.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ bool CoreFeatures::enableClonelessStateProgression = false;
2323
bool CoreFeatures::excludeYogaFromRawProps = false;
2424
bool CoreFeatures::enableMicrotasks = false;
2525
bool CoreFeatures::enableReportEventPaintTime = false;
26+
bool CoreFeatures::positionRelativeDefault = false;
2627

2728
} // namespace facebook::react

packages/react-native/ReactCommon/react/utils/CoreFeatures.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ class CoreFeatures {
6767
// Report paint time inside the Event Timing API implementation
6868
// (PerformanceObserver).
6969
static bool enableReportEventPaintTime;
70+
71+
// Sets the default position of nodes to be relative instead of static
72+
static bool positionRelativeDefault;
7073
};
7174

7275
} // namespace facebook::react

0 commit comments

Comments
 (0)