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 ad0296c3f010..1498b534ba1c 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 @@ -11,6 +11,7 @@ #include #include #include +#include namespace facebook::react { @@ -625,8 +626,11 @@ folly::dynamic AndroidTextInputProps::getDiffProps( result["letterSpacing"] = letterSpacing; } - if (fontSize != oldProps->fontSize) { - result["fontSize"] = fontSize; + if (!floatEquality( + textAttributes.fontSize, oldProps->textAttributes.fontSize)) { + result["fontSize"] = std::isnan(textAttributes.fontSize) + ? folly::dynamic(nullptr) + : textAttributes.fontSize; } if (textAlign != oldProps->textAlign) { 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 d549c31fd8d9..7928294876b1 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 @@ -55,6 +55,18 @@ TEST(AndroidTextInputPropsDiffTest, removedColorsAreSentAsNull) { } } +// 0 is the default of the flat field, and a font size of 0 hides the +// placeholder and new text. +TEST(AndroidTextInputPropsDiffTest, removedFontSizeIsSentAsNull) { + using folly::dynamic; + expectPayloadsMatchRawProps({ + {dynamic::object("fontSize", 20)}, + {dynamic::object("fontSize", 0)}, + {dynamic::object("fontSize", 20)}, + {dynamic::object("fontSize", nullptr)}, + }); +} + } // namespace facebook::react #endif