diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm index 6f84e8e24a4..d9e3b901824 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm @@ -413,8 +413,7 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu auto *scrollView = (RCTEnhancedScrollView *)_scrollView; if (oldScrollViewProps.snapToAlignment != newScrollViewProps.snapToAlignment) { - scrollView.snapToAlignment = - RCTNSStringFromString(toString(newScrollViewProps.snapToAlignment.value_or(ScrollViewSnapToAlignment::Start))); + scrollView.snapToAlignment = RCTNSStringFromString(toString(newScrollViewProps.snapToAlignment)); } scrollView.snapToStart = newScrollViewProps.snapToStart; diff --git a/packages/react-native/ReactCommon/react/renderer/components/scrollview/BaseScrollViewProps.cpp b/packages/react-native/ReactCommon/react/renderer/components/scrollview/BaseScrollViewProps.cpp index 5b6f2863435..cb5407ea853 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/scrollview/BaseScrollViewProps.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/scrollview/BaseScrollViewProps.cpp @@ -80,7 +80,7 @@ BaseScrollViewProps::BaseScrollViewProps( rawProps, "decelerationRate", sourceProps.decelerationRate, - kDefaultDecelerationRate)), + (Float)0.998)), endDraggingSensitivityMultiplier(convertRawProp( context, rawProps, @@ -427,7 +427,10 @@ SharedDebugStringConvertibleList BaseScrollViewProps::getDebugProps() const { "snapToInterval", snapToInterval, defaultScrollViewProps.snapToInterval), - debugStringConvertibleItem("snapToAlignment", snapToAlignment), + debugStringConvertibleItem( + "snapToAlignment", + snapToAlignment, + defaultScrollViewProps.snapToAlignment), debugStringConvertibleItem( "disableIntervalMomentum", disableIntervalMomentum, diff --git a/packages/react-native/ReactCommon/react/renderer/components/scrollview/BaseScrollViewProps.h b/packages/react-native/ReactCommon/react/renderer/components/scrollview/BaseScrollViewProps.h index 4e4b5d44785..3a3ebbe84b9 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/scrollview/BaseScrollViewProps.h +++ b/packages/react-native/ReactCommon/react/renderer/components/scrollview/BaseScrollViewProps.h @@ -41,13 +41,7 @@ class BaseScrollViewProps : public ViewProps { bool automaticallyAdjustContentInsets{}; bool automaticallyAdjustsScrollIndicatorInsets{true}; bool automaticallyAdjustKeyboardInsets{false}; -#ifdef ANDROID - // ReactScrollView's initial rate. - static constexpr Float kDefaultDecelerationRate = 0.985f; -#else - static constexpr Float kDefaultDecelerationRate = 0.998f; -#endif - Float decelerationRate{kDefaultDecelerationRate}; + Float decelerationRate{0.998f}; Float endDraggingSensitivityMultiplier{1}; bool directionalLockEnabled{}; ScrollViewIndicatorStyle indicatorStyle{}; @@ -69,7 +63,7 @@ class BaseScrollViewProps : public ViewProps { Point contentOffset{}; EdgeInsets scrollIndicatorInsets{}; Float snapToInterval{}; - std::optional snapToAlignment{}; + ScrollViewSnapToAlignment snapToAlignment{}; bool disableIntervalMomentum{false}; std::vector snapToOffsets{}; bool snapToStart{true}; diff --git a/packages/react-native/ReactCommon/react/renderer/components/scrollview/platform/android/react/renderer/components/scrollview/HostPlatformScrollViewProps.cpp b/packages/react-native/ReactCommon/react/renderer/components/scrollview/platform/android/react/renderer/components/scrollview/HostPlatformScrollViewProps.cpp index 2aa02d73854..a9a83ef67db 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/scrollview/platform/android/react/renderer/components/scrollview/HostPlatformScrollViewProps.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/scrollview/platform/android/react/renderer/components/scrollview/HostPlatformScrollViewProps.cpp @@ -49,13 +49,7 @@ HostPlatformScrollViewProps::HostPlatformScrollViewProps( rawProps, "endFillColor", sourceProps.endFillColor, - clearColor())), - scrollsChildToFocus(convertRawProp( - context, - rawProps, - "scrollsChildToFocus", - sourceProps.scrollsChildToFocus, - true)) {} + clearColor())) {} void HostPlatformScrollViewProps::setProp( const PropsParserContext& context, @@ -75,7 +69,6 @@ void HostPlatformScrollViewProps::setProp( RAW_SET_PROP_SWITCH_CASE_BASIC(fadingEdgeLength); RAW_SET_PROP_SWITCH_CASE_BASIC(overScrollMode); RAW_SET_PROP_SWITCH_CASE_BASIC(endFillColor); - RAW_SET_PROP_SWITCH_CASE_BASIC(scrollsChildToFocus); } } @@ -103,11 +96,7 @@ SharedDebugStringConvertibleList HostPlatformScrollViewProps::getDebugProps() debugStringConvertibleItem( "endFillColor", endFillColor, - defaultScrollViewProps.endFillColor), - debugStringConvertibleItem( - "scrollsChildToFocus", - scrollsChildToFocus, - defaultScrollViewProps.scrollsChildToFocus)}; + defaultScrollViewProps.endFillColor)}; } #endif @@ -312,9 +301,17 @@ folly::dynamic HostPlatformScrollViewProps::getDiffProps( } if (snapToAlignment != oldProps->snapToAlignment) { - result["snapToAlignment"] = snapToAlignment.has_value() - ? toString(*snapToAlignment) - : folly::dynamic(nullptr); + switch (snapToAlignment) { + case ScrollViewSnapToAlignment::Start: + result["snapToAlignment"] = "start"; + break; + case ScrollViewSnapToAlignment::Center: + result["snapToAlignment"] = "center"; + break; + case ScrollViewSnapToAlignment::End: + result["snapToAlignment"] = "end"; + break; + } } if (disableIntervalMomentum != oldProps->disableIntervalMomentum) { @@ -383,10 +380,6 @@ folly::dynamic HostPlatformScrollViewProps::getDiffProps( result["endFillColor"] = *endFillColor; } - if (scrollsChildToFocus != oldProps->scrollsChildToFocus) { - result["scrollsChildToFocus"] = scrollsChildToFocus; - } - return result; } diff --git a/packages/react-native/ReactCommon/react/renderer/components/scrollview/platform/android/react/renderer/components/scrollview/HostPlatformScrollViewProps.h b/packages/react-native/ReactCommon/react/renderer/components/scrollview/platform/android/react/renderer/components/scrollview/HostPlatformScrollViewProps.h index 49fcc1cb7f7..7ac321ec89f 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/scrollview/platform/android/react/renderer/components/scrollview/HostPlatformScrollViewProps.h +++ b/packages/react-native/ReactCommon/react/renderer/components/scrollview/platform/android/react/renderer/components/scrollview/HostPlatformScrollViewProps.h @@ -38,7 +38,6 @@ class HostPlatformScrollViewProps : public BaseScrollViewProps { folly::dynamic fadingEdgeLength{}; std::string overScrollMode{"auto"}; SharedColor endFillColor{clearColor()}; - bool scrollsChildToFocus{true}; #pragma mark - DebugStringConvertible diff --git a/packages/react-native/ReactCommon/react/renderer/components/scrollview/tests/ScrollViewPropsDiffTest.cpp b/packages/react-native/ReactCommon/react/renderer/components/scrollview/tests/ScrollViewPropsDiffTest.cpp deleted file mode 100644 index 8c46c2b2db8..00000000000 --- a/packages/react-native/ReactCommon/react/renderer/components/scrollview/tests/ScrollViewPropsDiffTest.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#include - -#include -#include - -#ifdef RN_SERIALIZABLE_STATE - -namespace facebook::react { - -namespace { - -using folly::dynamic; - -void expectPayloads(const std::vector& commits) { - expectPayloadsMatchRawProps(commits); -} - -} // namespace - -// ReactScrollViewManager has a setter for it; with -// enableExclusivePropsUpdateAndroid there is no rawProps fallback. -TEST(ScrollViewPropsDiffTest, emitsScrollsChildToFocus) { - expectPayloads({{dynamic::object("scrollsChildToFocus", false)}}); -} - -// Android ScrollViews start with snapping alignment disabled, and -// setSnapToAlignment disables it for null. -TEST( - ScrollViewPropsDiffTest, - keepsAnExplicitSnapToAlignmentStartApartFromUnset) { - expectPayloads({ - {dynamic::object("snapToAlignment", "start")}, - {dynamic::object("snapToAlignment", "center")}, - {dynamic::object("snapToAlignment", nullptr)}, - }); -} - -// Android ScrollViews start decelerating at 0.985 (ReactScrollViewHelper). -// A removed rate restores it; Props 1.5 sends null, which the setter reads as -// 0. -TEST(ScrollViewPropsDiffTest, emitsAnExplicitDecelerationRate) { - expectPayloads({ - {dynamic::object("decelerationRate", 0.998)}, - {dynamic::object("decelerationRate", nullptr), - dynamic::object("decelerationRate", 0.985)}, - }); -} - -// The ScrollView managers turn both off for null. -TEST(ScrollViewPropsDiffTest, removingNestedScrollAndMomentumEventsEmitsFalse) { - expectPayloads({ - {dynamic::object("nestedScrollEnabled", true)( - "sendMomentumEvents", true)}, - {dynamic::object("nestedScrollEnabled", nullptr)( - "sendMomentumEvents", nullptr), - dynamic::object("nestedScrollEnabled", false)( - "sendMomentumEvents", false)}, - }); -} - -} // namespace facebook::react - -#endif diff --git a/packages/react-native/ReactCommon/react/renderer/components/text/BaseTextProps.cpp b/packages/react-native/ReactCommon/react/renderer/components/text/BaseTextProps.cpp index 407445b5a6b..135463aa2d0 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/text/BaseTextProps.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/text/BaseTextProps.cpp @@ -13,8 +13,6 @@ #include #include -#include - namespace facebook::react { static TextAttributes convertRawProp( @@ -438,9 +436,7 @@ void BaseTextProps::appendTextAttributesProps( if (!floatEquality( textAttributes.letterSpacing, oldProps->textAttributes.letterSpacing)) { - result["letterSpacing"] = std::isnan(textAttributes.letterSpacing) - ? folly::dynamic(nullptr) - : textAttributes.letterSpacing; + result["letterSpacing"] = textAttributes.letterSpacing; } if (textAttributes.textTransform != oldProps->textAttributes.textTransform) { diff --git a/packages/react-native/ReactCommon/react/renderer/components/text/tests/ParagraphPropsDiffTest.cpp b/packages/react-native/ReactCommon/react/renderer/components/text/tests/ParagraphPropsDiffTest.cpp deleted file mode 100644 index 96ede0ca8e1..00000000000 --- a/packages/react-native/ReactCommon/react/renderer/components/text/tests/ParagraphPropsDiffTest.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#include - -#include -#include - -#ifdef RN_SERIALIZABLE_STATE - -namespace facebook::react { - -using folly::dynamic; - -// ReactTextViewManager resets letterSpacing to 0 for null; -// ReactTextView.setLetterSpacing ignores NaN. -TEST(ParagraphPropsDiffTest, removingLetterSpacingEmitsNull) { - expectPayloadsMatchRawProps({ - {dynamic::object("letterSpacing", 4.0)}, - {dynamic::object("letterSpacing", nullptr)}, - }); -} - -} // namespace facebook::react - -#endif diff --git a/scripts/cxx-api/api-snapshots/ReactAndroidFrameworksCxx.api b/scripts/cxx-api/api-snapshots/ReactAndroidFrameworksCxx.api index 18ddfbbbca4..02764f509d5 100644 --- a/scripts/cxx-api/api-snapshots/ReactAndroidFrameworksCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAndroidFrameworksCxx.api @@ -1439,9 +1439,8 @@ class facebook::react::BaseScrollViewProps : public facebook::react::HostPlatfor public facebook::react::Point contentOffset; public facebook::react::ScrollViewIndicatorStyle indicatorStyle; public facebook::react::ScrollViewKeyboardDismissMode keyboardDismissMode; - public static constexpr facebook::react::Float kDefaultDecelerationRate; + public facebook::react::ScrollViewSnapToAlignment snapToAlignment; public std::optional maintainVisibleContentPosition; - public std::optional snapToAlignment; public std::vector snapToOffsets; public void setProp(const facebook::react::PropsParserContext& context, facebook::react::RawPropsPropNameHash hash, const char* propName, const facebook::react::RawValue& value); } @@ -2050,7 +2049,6 @@ class facebook::react::HostPlatformScrollViewProps : public facebook::react::Bas public HostPlatformScrollViewProps() = default; public HostPlatformScrollViewProps(const facebook::react::PropsParserContext& context, const facebook::react::HostPlatformScrollViewProps& sourceProps, const facebook::react::RawProps& rawProps); public bool nestedScrollEnabled; - public bool scrollsChildToFocus; public bool sendMomentumEvents; public facebook::react::SharedColor endFillColor; public folly::dynamic fadingEdgeLength; diff --git a/scripts/cxx-api/api-snapshots/ReactAppleFrameworksCxx.api b/scripts/cxx-api/api-snapshots/ReactAppleFrameworksCxx.api index aebfecbad2b..535f7407c0a 100644 --- a/scripts/cxx-api/api-snapshots/ReactAppleFrameworksCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAppleFrameworksCxx.api @@ -4026,9 +4026,8 @@ class facebook::react::BaseScrollViewProps : public facebook::react::HostPlatfor public facebook::react::Point contentOffset; public facebook::react::ScrollViewIndicatorStyle indicatorStyle; public facebook::react::ScrollViewKeyboardDismissMode keyboardDismissMode; - public static constexpr facebook::react::Float kDefaultDecelerationRate; + public facebook::react::ScrollViewSnapToAlignment snapToAlignment; public std::optional maintainVisibleContentPosition; - public std::optional snapToAlignment; public std::vector snapToOffsets; public void setProp(const facebook::react::PropsParserContext& context, facebook::react::RawPropsPropNameHash hash, const char* propName, const facebook::react::RawValue& value); } diff --git a/scripts/cxx-api/api-snapshots/ReactCommonFrameworksCxx.api b/scripts/cxx-api/api-snapshots/ReactCommonFrameworksCxx.api index 7837bbde743..e85fe6f6fe5 100644 --- a/scripts/cxx-api/api-snapshots/ReactCommonFrameworksCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactCommonFrameworksCxx.api @@ -780,9 +780,8 @@ class facebook::react::BaseScrollViewProps : public facebook::react::HostPlatfor public facebook::react::Point contentOffset; public facebook::react::ScrollViewIndicatorStyle indicatorStyle; public facebook::react::ScrollViewKeyboardDismissMode keyboardDismissMode; - public static constexpr Float kDefaultDecelerationRate; + public facebook::react::ScrollViewSnapToAlignment snapToAlignment; public std::optional maintainVisibleContentPosition; - public std::optional snapToAlignment; public std::vector snapToOffsets; public void setProp(const facebook::react::PropsParserContext& context, facebook::react::RawPropsPropNameHash hash, const char* propName, const facebook::react::RawValue& value); }