Skip to content

Commit

Permalink
Set up gating for position: relative as default (#41711)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
joevilches authored and facebook-github-bot committed Nov 30, 2023
1 parent ee31ec9 commit 05ed007
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/react-native/React/Fabric/RCTSurfacePresenter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ - (RCTScheduler *)_createScheduler
CoreFeatures::enableClonelessStateProgression = true;
}

if (reactNativeConfig && reactNativeConfig->getBool("react_fabric:position_relative_default")) {
CoreFeatures::positionRelativeDefault = true;
}

auto componentRegistryFactory =
[factory = wrapManagedObject(_mountingManager.componentViewRegistry.componentViewFactory)](
const EventDispatcher::Weak &eventDispatcher, const ContextContainer::Shared &contextContainer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,7 @@ public class ReactFeatureFlags {
* when there is work to do.
*/
public static boolean enableOnDemandReactChoreographer = false;

/** When enabled, the default value of the position style property is relative. */
public static boolean positionRelativeDefault = false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,8 @@ void Binding::installFabricUIManager(
getFeatureFlagValue("enableClonelessStateProgression");
CoreFeatures::excludeYogaFromRawProps =
getFeatureFlagValue("excludeYogaFromRawProps");
CoreFeatures::positionRelativeDefault =
getFeatureFlagValue("positionRelativeDefault");

// RemoveDelete mega-op
ShadowViewMutation::PlatformSupportsRemoveDeleteTreeInstruction =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ YogaStylableProps::YogaStylableProps(
/*static*/ const yoga::Style& YogaStylableProps::defaultStyle() {
static const auto defaultStyle = []() {
yoga::Style style;
style.setPositionType(yoga::PositionType::Static);
style.setPositionType(
CoreFeatures::positionRelativeDefault ? yoga::PositionType::Relative
: yoga::PositionType::Static);
return style;
}();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ bool CoreFeatures::enableClonelessStateProgression = false;
bool CoreFeatures::excludeYogaFromRawProps = false;
bool CoreFeatures::enableMicrotasks = false;
bool CoreFeatures::enableReportEventPaintTime = false;
bool CoreFeatures::positionRelativeDefault = false;

} // namespace facebook::react
3 changes: 3 additions & 0 deletions packages/react-native/ReactCommon/react/utils/CoreFeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ class CoreFeatures {
// Report paint time inside the Event Timing API implementation
// (PerformanceObserver).
static bool enableReportEventPaintTime;

// Sets the default position of nodes to be relative instead of static
static bool positionRelativeDefault;
};

} // namespace facebook::react

0 comments on commit 05ed007

Please sign in to comment.