From 3a3b8bfa0c43ca1f029fc4b51abbf134d85905c1 Mon Sep 17 00:00:00 2001 From: Dawid Malecki Date: Wed, 4 Nov 2026 13:21:31 +0100 Subject: [PATCH] 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 --- .../androidtextinput/AndroidTextInputProps.cpp | 12 ++++++------ .../tests/AndroidTextInputPropsDiffTest.cpp | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/android/react/renderer/components/androidtextinput/AndroidTextInputProps.cpp b/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/android/react/renderer/components/androidtextinput/AndroidTextInputProps.cpp index 242d4ce659ff..ad0296c3f010 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/android/react/renderer/components/androidtextinput/AndroidTextInputProps.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/android/react/renderer/components/androidtextinput/AndroidTextInputProps.cpp @@ -446,23 +446,23 @@ folly::dynamic AndroidTextInputProps::getDiffProps( } if (placeholderTextColor != oldProps->placeholderTextColor) { - result["placeholderTextColor"] = *placeholderTextColor; + result["placeholderTextColor"] = colorOrNull(placeholderTextColor); } if (cursorColor != oldProps->cursorColor) { - result["cursorColor"] = *cursorColor; + result["cursorColor"] = colorOrNull(cursorColor); } if (selectionColor != oldProps->selectionColor) { - result["selectionColor"] = *selectionColor; + result["selectionColor"] = colorOrNull(selectionColor); } if (selectionHandleColor != oldProps->selectionHandleColor) { - result["selectionHandleColor"] = *selectionHandleColor; + result["selectionHandleColor"] = colorOrNull(selectionHandleColor); } if (underlineColorAndroid != oldProps->underlineColorAndroid) { - result["underlineColorAndroid"] = *underlineColorAndroid; + result["underlineColorAndroid"] = colorOrNull(underlineColorAndroid); } if (maxLength != oldProps->maxLength) { @@ -589,7 +589,7 @@ folly::dynamic AndroidTextInputProps::getDiffProps( } if (textShadowColor != oldProps->textShadowColor) { - result["textShadowColor"] = *textShadowColor; + result["textShadowColor"] = colorOrNull(textShadowColor); } if (textShadowRadius != oldProps->textShadowRadius) { diff --git a/packages/react-native/ReactCommon/react/renderer/components/textinput/tests/AndroidTextInputPropsDiffTest.cpp b/packages/react-native/ReactCommon/react/renderer/components/textinput/tests/AndroidTextInputPropsDiffTest.cpp index 79cd448b8fe6..d549c31fd8d9 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/textinput/tests/AndroidTextInputPropsDiffTest.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/textinput/tests/AndroidTextInputPropsDiffTest.cpp @@ -39,6 +39,22 @@ TEST(AndroidTextInputPropsDiffTest, colorIsSent) { }); } +TEST(AndroidTextInputPropsDiffTest, removedColorsAreSentAsNull) { + using folly::dynamic; + for (const auto* prop : + {"placeholderTextColor", + "selectionColor", + "selectionHandleColor", + "cursorColor", + "underlineColorAndroid", + "textShadowColor"}) { + expectPayloadsMatchRawProps({ + {dynamic::object(prop, static_cast(0xFFFF0000))}, + {dynamic::object(prop, nullptr)}, + }); + } +} + } // namespace facebook::react #endif