Skip to content

Commit 3a3b8bf

Browse files
coadoclaude
andcommitted
Send null when removing TextInput color props with props diffing
Summary: Removing `placeholderTextColor`, `selectionColor`, `selectionHandleColor`, `cursorColor` or `underlineColorAndroid` sent the value of the unset `SharedColor`, which is 0. `ReactTextInputManager` treats 0 as transparent and only restores the platform default for `null`, so the placeholder, the selection highlight, the handles or the cursor became invisible. These props now send `null` when removed, the same as raw props. An explicit `transparent` is still sent as 0. `textShadowColor` used the same pattern and is changed with them, although `ReactTextInputManager` has no setter for it. TextInput doesn't use props diffing yet: `getDiffPropsImplementationTarget()` returns `TextInput`, which doesn't match the `AndroidTextInput` component name. So the problem above only appears once that is enabled, and this change has no runtime effect until then. Changelog: [Internal] - Send null when removing TextInput color props with props diffing Test Plan: `AndroidTextInputPropsDiffTest.removedColorsAreSentAsNull` compares the props diffing payload with the raw props payload. It fails without this change and passes with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent e9cdacc commit 3a3b8bf

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

‎packages/react-native/ReactCommon/react/renderer/components/textinput/platform/android/react/renderer/components/androidtextinput/AndroidTextInputProps.cpp‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -446,23 +446,23 @@ folly::dynamic AndroidTextInputProps::getDiffProps(
446446
}
447447

448448
if (placeholderTextColor != oldProps->placeholderTextColor) {
449-
result["placeholderTextColor"] = *placeholderTextColor;
449+
result["placeholderTextColor"] = colorOrNull(placeholderTextColor);
450450
}
451451

452452
if (cursorColor != oldProps->cursorColor) {
453-
result["cursorColor"] = *cursorColor;
453+
result["cursorColor"] = colorOrNull(cursorColor);
454454
}
455455

456456
if (selectionColor != oldProps->selectionColor) {
457-
result["selectionColor"] = *selectionColor;
457+
result["selectionColor"] = colorOrNull(selectionColor);
458458
}
459459

460460
if (selectionHandleColor != oldProps->selectionHandleColor) {
461-
result["selectionHandleColor"] = *selectionHandleColor;
461+
result["selectionHandleColor"] = colorOrNull(selectionHandleColor);
462462
}
463463

464464
if (underlineColorAndroid != oldProps->underlineColorAndroid) {
465-
result["underlineColorAndroid"] = *underlineColorAndroid;
465+
result["underlineColorAndroid"] = colorOrNull(underlineColorAndroid);
466466
}
467467

468468
if (maxLength != oldProps->maxLength) {
@@ -589,7 +589,7 @@ folly::dynamic AndroidTextInputProps::getDiffProps(
589589
}
590590

591591
if (textShadowColor != oldProps->textShadowColor) {
592-
result["textShadowColor"] = *textShadowColor;
592+
result["textShadowColor"] = colorOrNull(textShadowColor);
593593
}
594594

595595
if (textShadowRadius != oldProps->textShadowRadius) {

‎packages/react-native/ReactCommon/react/renderer/components/textinput/tests/AndroidTextInputPropsDiffTest.cpp‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ TEST(AndroidTextInputPropsDiffTest, colorIsSent) {
3939
});
4040
}
4141

42+
TEST(AndroidTextInputPropsDiffTest, removedColorsAreSentAsNull) {
43+
using folly::dynamic;
44+
for (const auto* prop :
45+
{"placeholderTextColor",
46+
"selectionColor",
47+
"selectionHandleColor",
48+
"cursorColor",
49+
"underlineColorAndroid",
50+
"textShadowColor"}) {
51+
expectPayloadsMatchRawProps<AndroidTextInputProps>({
52+
{dynamic::object(prop, static_cast<int32_t>(0xFFFF0000))},
53+
{dynamic::object(prop, nullptr)},
54+
});
55+
}
56+
}
57+
4258
} // namespace facebook::react
4359

4460
#endif

0 commit comments

Comments
 (0)