From 63c0287c8382bd594e1bda66ed7d4c6ec41e00f9 Mon Sep 17 00:00:00 2001 From: Nick Lefever Date: Tue, 13 May 2025 05:27:17 -0700 Subject: [PATCH] Add getDiffProps for TextInput component - base text input props (#51275) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/51275 See title Changelog: [Internal] Reviewed By: rshest Differential Revision: D74610301 fbshipit-source-id: cbd3f8eab75838f8b68a668ec44d3e14aa591f25 --- .../AndroidTextInputProps.cpp | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) 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 fecf2356132..fb45b2cf8ab 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 @@ -356,6 +356,15 @@ SharedDebugStringConvertibleList AndroidTextInputProps::getDebugProps() const { } #endif +static folly::dynamic toDynamic( + const std::vector& acceptDragAndDropTypes) { + folly::dynamic acceptDragAndDropTypesArray = folly::dynamic::array(); + for (const auto& acceptDragAndDropType : acceptDragAndDropTypes) { + acceptDragAndDropTypesArray.push_back(acceptDragAndDropType); + } + return acceptDragAndDropTypesArray; +} + folly::dynamic AndroidTextInputProps::getDiffProps( const Props* prevProps) const { static const auto defaultProps = AndroidTextInputProps(); @@ -409,6 +418,81 @@ folly::dynamic AndroidTextInputProps::getDiffProps( toString(paragraphAttributes.android_hyphenationFrequency); } + // Base text input props + if (defaultValue != oldProps->defaultValue) { + result["defaultValue"] = defaultValue; + } + + if (placeholder != oldProps->placeholder) { + result["placeholder"] = placeholder; + } + + if (placeholderTextColor != oldProps->placeholderTextColor) { + result["placeholderTextColor"] = *placeholderTextColor; + } + + if (cursorColor != oldProps->cursorColor) { + result["cursorColor"] = *cursorColor; + } + + if (selectionColor != oldProps->selectionColor) { + result["selectionColor"] = *selectionColor; + } + + if (selectionHandleColor != oldProps->selectionHandleColor) { + result["selectionHandleColor"] = *selectionHandleColor; + } + + if (underlineColorAndroid != oldProps->underlineColorAndroid) { + result["underlineColorAndroid"] = *underlineColorAndroid; + } + + if (maxLength != oldProps->maxLength) { + result["maxLength"] = maxLength; + } + + if (text != oldProps->text) { + result["text"] = text; + } + + if (mostRecentEventCount != oldProps->mostRecentEventCount) { + result["mostRecentEventCount"] = mostRecentEventCount; + } + + if (autoFocus != oldProps->autoFocus) { + result["autoFocus"] = autoFocus; + } + + if (autoCapitalize != oldProps->autoCapitalize) { + result["autoCapitalize"] = autoCapitalize; + } + + if (editable != oldProps->editable) { + result["editable"] = editable; + } + + if (readOnly != oldProps->readOnly) { + result["readOnly"] = readOnly; + } + + if (submitBehavior != oldProps->submitBehavior) { + result["submitBehavior"] = toDynamic(submitBehavior); + } + + if (multiline != oldProps->multiline) { + result["multiline"] = multiline; + } + + if (disableKeyboardShortcuts != oldProps->disableKeyboardShortcuts) { + result["disableKeyboardShortcuts"] = disableKeyboardShortcuts; + } + + if (acceptDragAndDropTypes != oldProps->acceptDragAndDropTypes) { + result["acceptDragAndDropTypes"] = acceptDragAndDropTypes.has_value() + ? toDynamic(acceptDragAndDropTypes.value()) + : nullptr; + } + return result; }