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 @@ -33,6 +33,12 @@ hasValue(const RawProps& rawProps, bool defaultValue, const char* name) {
return false;
}

// ReactTextInputManager resets a color to the platform default for null, while
// 0 is transparent.
static folly::dynamic colorOrNull(const SharedColor& color) {
return color ? folly::dynamic(*color) : folly::dynamic(nullptr);
}

AndroidTextInputProps::AndroidTextInputProps(
const PropsParserContext &context,
const AndroidTextInputProps &sourceProps,
Expand Down Expand Up @@ -610,6 +616,11 @@ folly::dynamic AndroidTextInputProps::getDiffProps(
result["textTransform"] = textTransform;
}

if (textAttributes.foregroundColor !=
oldProps->textAttributes.foregroundColor) {
result["color"] = colorOrNull(textAttributes.foregroundColor);
}

if (letterSpacing != oldProps->letterSpacing) {
result["letterSpacing"] = letterSpacing;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ TEST(AndroidTextInputPropsDiffTest, eventHandlerPropsAreSent) {
});
}

// Text typed into an empty input uses the color of the native view, not the
// color in the attributed string of the state.
TEST(AndroidTextInputPropsDiffTest, colorIsSent) {
using folly::dynamic;
expectPayloadsMatchRawProps<AndroidTextInputProps>({
{dynamic::object("color", static_cast<int32_t>(0xFFFF0000))},
{dynamic::object("color", 0)},
{dynamic::object("color", nullptr)},
});
}

} // namespace facebook::react

#endif
Loading