mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
TextInput: support modifying TextInputs with multiple Fragments (Cxx side)
Summary: Support for modifying AndroidTextInputs with multiple Fragments was added on the Java side in a previous diff. This diff adds support on the C++ side for the following scenario: A <TextInput> is initially given contents via children <Text> notes, which represents multiple Fragments (that could have different TextAttributes like color, font size, backgroundcolor, etc). The Android EditText view must get this initial data, and then all updates after that on the Android side must flow to C++ so that the C++ ShadowNode can perform layout and measurement with up-to-date data. At the same time, the <TextInput> node could be updated from the JS side. All else equal, this would cause the native Android EditText to be replaced with the old, original contents of the <TextInput> that may not have been updated at all from the JS side. To mitigate this, we keep track of two AttributedStrings with Fragments on the C++ side: the AttributedString representing the values coming from <TextInput> children, from JS (`treeAttributedString`); and the AttributedString representing the current value the user is interacting with (`attributedString`). If the children from JS don't change, we don't update Android/Java with that AttributedString. If the children from JS do change, we overwrite any user input with the tree from JS. Changelog: [Internal] Reviewed By: shergin, mdvacca Differential Revision: D18785976 fbshipit-source-id: a1f3a935e02379cabca8ab62a39cb3c0cf3fbca5
This commit is contained in:
committed by
Facebook Github Bot
parent
0bae47434e
commit
0556e86d09
@@ -15,6 +15,7 @@ namespace react {
|
||||
|
||||
#ifdef ANDROID
|
||||
folly::dynamic AndroidTextInputState::getDynamic() const {
|
||||
// Java doesn't need all fields, so we don't pass them along.
|
||||
folly::dynamic newState = folly::dynamic::object();
|
||||
newState["mostRecentEventCount"] = mostRecentEventCount;
|
||||
newState["attributedString"] = toDynamic(attributedString);
|
||||
|
||||
Reference in New Issue
Block a user