Skip to content

Commit 1829aec

Browse files
Jacob Wirthmeta-codesync[bot]
authored andcommitted
Revert D125438443: Fix Text and ScrollView payloads that Props 2.0 sends wrong or drops
Differential Revision: D125438443 Original commit changeset: b08abf57a6bf Original Phabricator Diff: D125438443 fbshipit-source-id: 6f5654412bbf33f99ae8e9abda5999444a3ea7e5
1 parent 973b31b commit 1829aec

11 files changed

Lines changed: 25 additions & 145 deletions

File tree

‎packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,7 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
413413

414414
auto *scrollView = (RCTEnhancedScrollView *)_scrollView;
415415
if (oldScrollViewProps.snapToAlignment != newScrollViewProps.snapToAlignment) {
416-
scrollView.snapToAlignment =
417-
RCTNSStringFromString(toString(newScrollViewProps.snapToAlignment.value_or(ScrollViewSnapToAlignment::Start)));
416+
scrollView.snapToAlignment = RCTNSStringFromString(toString(newScrollViewProps.snapToAlignment));
418417
}
419418

420419
scrollView.snapToStart = newScrollViewProps.snapToStart;

‎packages/react-native/ReactCommon/react/renderer/components/scrollview/BaseScrollViewProps.cpp‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ BaseScrollViewProps::BaseScrollViewProps(
8080
rawProps,
8181
"decelerationRate",
8282
sourceProps.decelerationRate,
83-
kDefaultDecelerationRate)),
83+
(Float)0.998)),
8484
endDraggingSensitivityMultiplier(convertRawProp(
8585
context,
8686
rawProps,
@@ -427,7 +427,10 @@ SharedDebugStringConvertibleList BaseScrollViewProps::getDebugProps() const {
427427
"snapToInterval",
428428
snapToInterval,
429429
defaultScrollViewProps.snapToInterval),
430-
debugStringConvertibleItem("snapToAlignment", snapToAlignment),
430+
debugStringConvertibleItem(
431+
"snapToAlignment",
432+
snapToAlignment,
433+
defaultScrollViewProps.snapToAlignment),
431434
debugStringConvertibleItem(
432435
"disableIntervalMomentum",
433436
disableIntervalMomentum,

‎packages/react-native/ReactCommon/react/renderer/components/scrollview/BaseScrollViewProps.h‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,7 @@ class BaseScrollViewProps : public ViewProps {
4141
bool automaticallyAdjustContentInsets{};
4242
bool automaticallyAdjustsScrollIndicatorInsets{true};
4343
bool automaticallyAdjustKeyboardInsets{false};
44-
#ifdef ANDROID
45-
// ReactScrollView's initial rate.
46-
static constexpr Float kDefaultDecelerationRate = 0.985f;
47-
#else
48-
static constexpr Float kDefaultDecelerationRate = 0.998f;
49-
#endif
50-
Float decelerationRate{kDefaultDecelerationRate};
44+
Float decelerationRate{0.998f};
5145
Float endDraggingSensitivityMultiplier{1};
5246
bool directionalLockEnabled{};
5347
ScrollViewIndicatorStyle indicatorStyle{};
@@ -69,7 +63,7 @@ class BaseScrollViewProps : public ViewProps {
6963
Point contentOffset{};
7064
EdgeInsets scrollIndicatorInsets{};
7165
Float snapToInterval{};
72-
std::optional<ScrollViewSnapToAlignment> snapToAlignment{};
66+
ScrollViewSnapToAlignment snapToAlignment{};
7367
bool disableIntervalMomentum{false};
7468
std::vector<Float> snapToOffsets{};
7569
bool snapToStart{true};

‎packages/react-native/ReactCommon/react/renderer/components/scrollview/platform/android/react/renderer/components/scrollview/HostPlatformScrollViewProps.cpp‎

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,7 @@ HostPlatformScrollViewProps::HostPlatformScrollViewProps(
4949
rawProps,
5050
"endFillColor",
5151
sourceProps.endFillColor,
52-
clearColor())),
53-
scrollsChildToFocus(convertRawProp(
54-
context,
55-
rawProps,
56-
"scrollsChildToFocus",
57-
sourceProps.scrollsChildToFocus,
58-
true)) {}
52+
clearColor())) {}
5953

6054
void HostPlatformScrollViewProps::setProp(
6155
const PropsParserContext& context,
@@ -75,7 +69,6 @@ void HostPlatformScrollViewProps::setProp(
7569
RAW_SET_PROP_SWITCH_CASE_BASIC(fadingEdgeLength);
7670
RAW_SET_PROP_SWITCH_CASE_BASIC(overScrollMode);
7771
RAW_SET_PROP_SWITCH_CASE_BASIC(endFillColor);
78-
RAW_SET_PROP_SWITCH_CASE_BASIC(scrollsChildToFocus);
7972
}
8073
}
8174

@@ -103,11 +96,7 @@ SharedDebugStringConvertibleList HostPlatformScrollViewProps::getDebugProps()
10396
debugStringConvertibleItem(
10497
"endFillColor",
10598
endFillColor,
106-
defaultScrollViewProps.endFillColor),
107-
debugStringConvertibleItem(
108-
"scrollsChildToFocus",
109-
scrollsChildToFocus,
110-
defaultScrollViewProps.scrollsChildToFocus)};
99+
defaultScrollViewProps.endFillColor)};
111100
}
112101
#endif
113102

@@ -312,9 +301,17 @@ folly::dynamic HostPlatformScrollViewProps::getDiffProps(
312301
}
313302

314303
if (snapToAlignment != oldProps->snapToAlignment) {
315-
result["snapToAlignment"] = snapToAlignment.has_value()
316-
? toString(*snapToAlignment)
317-
: folly::dynamic(nullptr);
304+
switch (snapToAlignment) {
305+
case ScrollViewSnapToAlignment::Start:
306+
result["snapToAlignment"] = "start";
307+
break;
308+
case ScrollViewSnapToAlignment::Center:
309+
result["snapToAlignment"] = "center";
310+
break;
311+
case ScrollViewSnapToAlignment::End:
312+
result["snapToAlignment"] = "end";
313+
break;
314+
}
318315
}
319316

320317
if (disableIntervalMomentum != oldProps->disableIntervalMomentum) {
@@ -383,10 +380,6 @@ folly::dynamic HostPlatformScrollViewProps::getDiffProps(
383380
result["endFillColor"] = *endFillColor;
384381
}
385382

386-
if (scrollsChildToFocus != oldProps->scrollsChildToFocus) {
387-
result["scrollsChildToFocus"] = scrollsChildToFocus;
388-
}
389-
390383
return result;
391384
}
392385

‎packages/react-native/ReactCommon/react/renderer/components/scrollview/platform/android/react/renderer/components/scrollview/HostPlatformScrollViewProps.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ class HostPlatformScrollViewProps : public BaseScrollViewProps {
3838
folly::dynamic fadingEdgeLength{};
3939
std::string overScrollMode{"auto"};
4040
SharedColor endFillColor{clearColor()};
41-
bool scrollsChildToFocus{true};
4241

4342
#pragma mark - DebugStringConvertible
4443

‎packages/react-native/ReactCommon/react/renderer/components/scrollview/tests/ScrollViewPropsDiffTest.cpp‎

Lines changed: 0 additions & 70 deletions
This file was deleted.

‎packages/react-native/ReactCommon/react/renderer/components/text/BaseTextProps.cpp‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
#include <react/renderer/debug/DebugStringConvertibleItem.h>
1414
#include <react/utils/FloatComparison.h>
1515

16-
#include <cmath>
17-
1816
namespace facebook::react {
1917

2018
static TextAttributes convertRawProp(
@@ -438,9 +436,7 @@ void BaseTextProps::appendTextAttributesProps(
438436
if (!floatEquality(
439437
textAttributes.letterSpacing,
440438
oldProps->textAttributes.letterSpacing)) {
441-
result["letterSpacing"] = std::isnan(textAttributes.letterSpacing)
442-
? folly::dynamic(nullptr)
443-
: textAttributes.letterSpacing;
439+
result["letterSpacing"] = textAttributes.letterSpacing;
444440
}
445441

446442
if (textAttributes.textTransform != oldProps->textAttributes.textTransform) {

‎packages/react-native/ReactCommon/react/renderer/components/text/tests/ParagraphPropsDiffTest.cpp‎

Lines changed: 0 additions & 30 deletions
This file was deleted.

‎scripts/cxx-api/api-snapshots/ReactAndroidFrameworksCxx.api‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,9 +1439,8 @@ class facebook::react::BaseScrollViewProps : public facebook::react::HostPlatfor
14391439
public facebook::react::Point contentOffset;
14401440
public facebook::react::ScrollViewIndicatorStyle indicatorStyle;
14411441
public facebook::react::ScrollViewKeyboardDismissMode keyboardDismissMode;
1442-
public static constexpr facebook::react::Float kDefaultDecelerationRate;
1442+
public facebook::react::ScrollViewSnapToAlignment snapToAlignment;
14431443
public std::optional<facebook::react::ScrollViewMaintainVisibleContentPosition> maintainVisibleContentPosition;
1444-
public std::optional<facebook::react::ScrollViewSnapToAlignment> snapToAlignment;
14451444
public std::vector<facebook::react::Float> snapToOffsets;
14461445
public void setProp(const facebook::react::PropsParserContext& context, facebook::react::RawPropsPropNameHash hash, const char* propName, const facebook::react::RawValue& value);
14471446
}
@@ -2050,7 +2049,6 @@ class facebook::react::HostPlatformScrollViewProps : public facebook::react::Bas
20502049
public HostPlatformScrollViewProps() = default;
20512050
public HostPlatformScrollViewProps(const facebook::react::PropsParserContext& context, const facebook::react::HostPlatformScrollViewProps& sourceProps, const facebook::react::RawProps& rawProps);
20522051
public bool nestedScrollEnabled;
2053-
public bool scrollsChildToFocus;
20542052
public bool sendMomentumEvents;
20552053
public facebook::react::SharedColor endFillColor;
20562054
public folly::dynamic fadingEdgeLength;

‎scripts/cxx-api/api-snapshots/ReactAppleFrameworksCxx.api‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4026,9 +4026,8 @@ class facebook::react::BaseScrollViewProps : public facebook::react::HostPlatfor
40264026
public facebook::react::Point contentOffset;
40274027
public facebook::react::ScrollViewIndicatorStyle indicatorStyle;
40284028
public facebook::react::ScrollViewKeyboardDismissMode keyboardDismissMode;
4029-
public static constexpr facebook::react::Float kDefaultDecelerationRate;
4029+
public facebook::react::ScrollViewSnapToAlignment snapToAlignment;
40304030
public std::optional<facebook::react::ScrollViewMaintainVisibleContentPosition> maintainVisibleContentPosition;
4031-
public std::optional<facebook::react::ScrollViewSnapToAlignment> snapToAlignment;
40324031
public std::vector<facebook::react::Float> snapToOffsets;
40334032
public void setProp(const facebook::react::PropsParserContext& context, facebook::react::RawPropsPropNameHash hash, const char* propName, const facebook::react::RawValue& value);
40344033
}

0 commit comments

Comments
 (0)