Skip to content

Commit 5c8f2fb

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 3099c1e commit 5c8f2fb

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
@@ -495,23 +495,23 @@ folly::dynamic AndroidTextInputProps::getDiffProps(
495495
}
496496

497497
if (placeholderTextColor != oldProps->placeholderTextColor) {
498-
result["placeholderTextColor"] = *placeholderTextColor;
498+
result["placeholderTextColor"] = colorOrNull(placeholderTextColor);
499499
}
500500

501501
if (cursorColor != oldProps->cursorColor) {
502-
result["cursorColor"] = *cursorColor;
502+
result["cursorColor"] = colorOrNull(cursorColor);
503503
}
504504

505505
if (selectionColor != oldProps->selectionColor) {
506-
result["selectionColor"] = *selectionColor;
506+
result["selectionColor"] = colorOrNull(selectionColor);
507507
}
508508

509509
if (selectionHandleColor != oldProps->selectionHandleColor) {
510-
result["selectionHandleColor"] = *selectionHandleColor;
510+
result["selectionHandleColor"] = colorOrNull(selectionHandleColor);
511511
}
512512

513513
if (underlineColorAndroid != oldProps->underlineColorAndroid) {
514-
result["underlineColorAndroid"] = *underlineColorAndroid;
514+
result["underlineColorAndroid"] = colorOrNull(underlineColorAndroid);
515515
}
516516

517517
if (maxLength != oldProps->maxLength) {
@@ -638,7 +638,7 @@ folly::dynamic AndroidTextInputProps::getDiffProps(
638638
}
639639

640640
if (textShadowColor != oldProps->textShadowColor) {
641-
result["textShadowColor"] = *textShadowColor;
641+
result["textShadowColor"] = colorOrNull(textShadowColor);
642642
}
643643

644644
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)