Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,34 @@ describe('<ScrollView>', () => {
</rn-scrollView>,
);
});

it('returns persistentScrollbar to its default once the prop is removed', () => {
const root = Fantom.createRoot();

Fantom.runTask(() => {
root.render(<ScrollView persistentScrollbar={true} />);
});

expect(
root.getRenderedOutput({props: ['persistentScrollbar']}).toJSX(),
).toEqual(
<rn-scrollView persistentScrollbar="true">
<rn-view />
</rn-scrollView>,
);

Fantom.runTask(() => {
root.render(<ScrollView />);
});

expect(
root.getRenderedOutput({props: ['persistentScrollbar']}).toJSX(),
).toEqual(
<rn-scrollView>
<rn-view />
</rn-scrollView>,
);
});
});

describe('ref', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ let reactFabricText = RNTarget(
let reactFabricTextInput = RNTarget(
name: .reactFabricTextInput,
path: "ReactCommon/react/renderer/components/textinput",
excludedPaths: ["platform/android", "platform/macos"],
excludedPaths: ["tests", "platform/android", "platform/macos"],
dependencies: [.reactNativeDependencies, .reactCore, .reactJsiExecutor, .reactTurboModuleCore, .jsi, .logger, .reactDebug, .reactFeatureFlags, .reactUtils, .reactRuntimeScheduler, .reactCxxReact, .yoga, .reactRendererDebug, .reactGraphics, .reactFabric, .reactTurboModuleBridging, .reactFabricTextLayoutManager, .reactImageManagerApple],
sources: [".", "platform/ios"]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ BaseScrollViewProps::BaseScrollViewProps(
rawProps,
"persistentScrollbar",
sourceProps.persistentScrollbar,
true)),
false)),
horizontal(convertRawProp(
context,
rawProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ HostPlatformScrollViewProps::HostPlatformScrollViewProps(
rawProps,
"sendMomentumEvents",
sourceProps.sendMomentumEvents,
true)),
false)),
nestedScrollEnabled(convertRawProp(
context,
rawProps,
"nestedScrollEnabled",
sourceProps.nestedScrollEnabled,
true)),
false)),
fadingEdgeLength(convertRawProp(
context,
rawProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ BaseTextInputProps::BaseTextInputProps(
rawProps,
"editable",
sourceProps.editable,
{})),
true)),
readOnly(convertRawProp(
context,
rawProps,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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 <gtest/gtest.h>

#include <react/renderer/components/textinput/BaseTextInputProps.h>
#include <react/renderer/core/RawProps.h>
#include <react/renderer/core/RawPropsParser.h>

namespace facebook::react {

namespace {

BaseTextInputProps parse(
const folly::dynamic& rawPropsValue,
const BaseTextInputProps& sourceProps = BaseTextInputProps()) {
ContextContainer contextContainer{};
PropsParserContext parserContext{-1, contextContainer};

auto raw = RawProps(rawPropsValue);
auto parser = RawPropsParser();
parser.prepare<BaseTextInputProps>();
raw.parse(parser);

return {parserContext, sourceProps, raw};
}

} // namespace

TEST(BaseTextInputPropsTest, removed_editable_returns_to_its_default) {
auto readOnly = parse(folly::dynamic::object("editable", false));
ASSERT_FALSE(readOnly.editable);

auto removed = parse(folly::dynamic::object("editable", nullptr), readOnly);

EXPECT_EQ(removed.editable, BaseTextInputProps().editable);
}

} // namespace facebook::react
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ BaseViewProps::BaseViewProps(
rawProps,
"shadowOffset",
sourceProps.shadowOffset,
{})),
Size{0, -3})),
shadowOpacity(convertRawProp(
context,
rawProps,
Expand All @@ -192,7 +192,7 @@ BaseViewProps::BaseViewProps(
rawProps,
"shadowRadius",
sourceProps.shadowRadius,
{})),
(Float)3)),
cursor(
convertRawProp(context, rawProps, "cursor", sourceProps.cursor, {})),
boxShadow(convertRawProp(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* 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 <gtest/gtest.h>

#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/RawProps.h>
#include <react/renderer/core/RawPropsParser.h>

namespace facebook::react {

namespace {

ViewProps parse(
const folly::dynamic& rawPropsValue,
const ViewProps& sourceProps = ViewProps()) {
ContextContainer contextContainer{};
PropsParserContext parserContext{-1, contextContainer};

auto raw = RawProps(rawPropsValue);
auto parser = RawPropsParser();
parser.prepare<ViewProps>();
raw.parse(parser);

return {parserContext, sourceProps, raw};
}

} // namespace

TEST(ViewPropsTest, removed_shadow_radius_returns_to_its_default) {
auto withShadowRadius = parse(folly::dynamic::object("shadowRadius", 8));
ASSERT_EQ(withShadowRadius.shadowRadius, 8);

auto removed =
parse(folly::dynamic::object("shadowRadius", nullptr), withShadowRadius);

EXPECT_EQ(removed.shadowRadius, ViewProps().shadowRadius);
}

TEST(ViewPropsTest, removed_shadow_offset_returns_to_its_default) {
auto withShadowOffset = parse(
folly::dynamic::object(
"shadowOffset", folly::dynamic::object("width", 2)("height", 4)));
ASSERT_EQ(withShadowOffset.shadowOffset, (Size{.width = 2, .height = 4}));

auto removed =
parse(folly::dynamic::object("shadowOffset", nullptr), withShadowOffset);

const auto defaultShadowOffset = ViewProps().shadowOffset;
EXPECT_EQ(removed.shadowOffset.width, defaultShadowOffset.width);
EXPECT_EQ(removed.shadowOffset.height, defaultShadowOffset.height);
}

} // namespace facebook::react
Loading