From fcde6525f715acdd4bba9c278ef59c976a2cd96f Mon Sep 17 00:00:00 2001 From: Andy Zolyak Date: Sat, 26 Mar 2022 15:57:57 -0400 Subject: [PATCH] Fix ReactEditText so it works with Android Emoji2 automatic support --- .../facebook/react/views/textinput/ReactEditText.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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 51deec2f262075..4847b9b5d86e7d 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 @@ -101,7 +101,7 @@ public class ReactEditText extends AppCompatEditText private @Nullable SelectionWatcher mSelectionWatcher; private @Nullable ContentSizeWatcher mContentSizeWatcher; private @Nullable ScrollWatcher mScrollWatcher; - private final InternalKeyListener mKeyListener; + private InternalKeyListener mKeyListener; private boolean mDetectScrollMovement = false; private boolean mOnKeyPress = false; private TextAttributes mTextAttributes; @@ -140,7 +140,9 @@ public ReactEditText(Context context) { mListeners = null; mTextWatcherDelegator = null; mStagedInputType = getInputType(); - mKeyListener = new InternalKeyListener(); + if (mKeyListener == null) { + mKeyListener = new InternalKeyListener(); + } mScrollWatcher = null; mTextAttributes = new TextAttributes(); @@ -451,6 +453,10 @@ public void setInputType(int type) { // We override the KeyListener so that all keys on the soft input keyboard as well as hardware // keyboards work. Some KeyListeners like DigitsKeyListener will display the keyboard but not // accept all input from it + if (mKeyListener == null) { + mKeyListener = new InternalKeyListener(); + } + mKeyListener.setInputType(type); setKeyListener(mKeyListener); }