diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java index 5c191f98d5d..663c1443b28 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java @@ -36,6 +36,9 @@ import androidx.core.view.AccessibilityDelegateCompat; import androidx.core.view.ViewCompat; import com.facebook.infer.annotation.Assertions; import com.facebook.react.bridge.ReactContext; +import com.facebook.react.bridge.WritableMap; +import com.facebook.react.bridge.WritableNativeMap; +import com.facebook.react.uimanager.StateWrapper; import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.views.text.ReactSpan; import com.facebook.react.views.text.ReactTextUpdate; @@ -92,6 +95,8 @@ public class ReactEditText extends EditText { private ReactViewBackgroundManager mReactBackgroundManager; + protected @Nullable StateWrapper mStateWrapper = null; + private static final KeyListener sKeyListener = QwertyKeyListener.getInstanceForFullKeyboard(); public ReactEditText(Context context) { @@ -274,7 +279,17 @@ public class ReactEditText extends EditText { } public void setMostRecentEventCount(int mostRecentEventCount) { + if (mMostRecentEventCount == mostRecentEventCount) { + return; + } + mMostRecentEventCount = mostRecentEventCount; + + if (mStateWrapper != null) { + WritableMap map = new WritableNativeMap(); + map.putInt("mostRecentEventCount", mMostRecentEventCount); + mStateWrapper.updateState(map); + } } public void setScrollWatcher(ScrollWatcher scrollWatcher) { @@ -416,8 +431,9 @@ public class ReactEditText extends EditText { mTypefaceDirty = false; - Typeface newTypeface = ReactTypefaceUtils.applyStyles( - getTypeface(), mFontStyle, mFontWeight, mFontFamily, getContext().getAssets()); + Typeface newTypeface = + ReactTypefaceUtils.applyStyles( + getTypeface(), mFontStyle, mFontWeight, mFontFamily, getContext().getAssets()); setTypeface(newTypeface); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java index 5aa6b6ac4a2..0f7994195fe 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java @@ -1072,10 +1072,11 @@ public class ReactTextInputManager extends BaseViewManagerparagraphAttributes, textLayoutManager_}); + setStateData(AndroidTextInputState{state.mostRecentEventCount, + attributedString, + getProps()->paragraphAttributes, + textLayoutManager_}); } #pragma mark - LayoutableShadowNode diff --git a/ReactCommon/fabric/components/textinput/androidtextinput/AndroidTextInputState.cpp b/ReactCommon/fabric/components/textinput/androidtextinput/AndroidTextInputState.cpp index 197e9cf9bf7..4a53da92f24 100644 --- a/ReactCommon/fabric/components/textinput/androidtextinput/AndroidTextInputState.cpp +++ b/ReactCommon/fabric/components/textinput/androidtextinput/AndroidTextInputState.cpp @@ -16,6 +16,7 @@ namespace react { #ifdef ANDROID folly::dynamic AndroidTextInputState::getDynamic() const { folly::dynamic newState = folly::dynamic::object(); + newState["mostRecentEventCount"] = mostRecentEventCount; newState["attributedString"] = toDynamic(attributedString); newState["paragraphAttributes"] = toDynamic(paragraphAttributes); newState["hash"] = newState["attributedString"]["hash"]; diff --git a/ReactCommon/fabric/components/textinput/androidtextinput/AndroidTextInputState.h b/ReactCommon/fabric/components/textinput/androidtextinput/AndroidTextInputState.h index 11f1d516f6c..f311609021e 100644 --- a/ReactCommon/fabric/components/textinput/androidtextinput/AndroidTextInputState.h +++ b/ReactCommon/fabric/components/textinput/androidtextinput/AndroidTextInputState.h @@ -24,6 +24,8 @@ namespace react { */ class AndroidTextInputState final { public: + int64_t mostRecentEventCount{0}; + /* * All content of component represented as an `AttributedString`. */ @@ -44,10 +46,12 @@ class AndroidTextInputState final { #ifdef ANDROID AndroidTextInputState( + int64_t mostRecentEventCount, AttributedString const &attributedString, ParagraphAttributes const ¶graphAttributes, SharedTextLayoutManager const &layoutManager) - : attributedString(attributedString), + : mostRecentEventCount(mostRecentEventCount), + attributedString(attributedString), paragraphAttributes(paragraphAttributes), layoutManager(layoutManager) {} AndroidTextInputState() = default;