From de42893d014e7fe71fad1b7993bfd02a7f3ebf4f Mon Sep 17 00:00:00 2001 From: David Vacca Date: Fri, 26 Jan 2024 15:50:31 -0800 Subject: [PATCH] Fix TextInput-textStyles-e2e test (#42685) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/42685 This diff fixes the TextInput-textStyles-e2e test. The rootcause of this issue is that we were updating the lineHeight of ReactEditText (AppCompatEditText) when lineHeight is set as a prop from React. This is a problem, because one one side lineHeight is managed by React Native (setting styles in the spannables) and on the other side we ar calling setLineHeight on AppCompatEditText, which breaks the rendering. We should only manage lineHeight using RN styles, that's why I'm removing call to super.setLineHeight() Changelog: [internal] internal Reviewed By: NickGerleman Differential Revision: D53142429 fbshipit-source-id: cedf803171a490afa67252e9e7f83749502326e6 --- .../com/facebook/react/views/textinput/ReactEditText.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java index f2b3e5d28c9..0904f430a68 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java @@ -83,6 +83,7 @@ import java.util.Objects; * VisibleForTesting from {@link TextInputEventsTestCase}. */ public class ReactEditText extends AppCompatEditText { + private final InputMethodManager mInputMethodManager; private final String TAG = ReactEditText.class.getSimpleName(); public static final boolean DEBUG_MODE = ReactBuildConfig.DEBUG && false; @@ -273,9 +274,7 @@ public class ReactEditText extends AppCompatEditText { @Override public void setLineHeight(int lineHeight) { mTextAttributes.setLineHeight(lineHeight); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - super.setLineHeight(lineHeight); - } + // We don't call super.setLineHeight() because LineHeight is fully managed by ReactNative } @Override @@ -1232,6 +1231,7 @@ public class ReactEditText extends AppCompatEditText { * changed by the user, and not explicitly set by JS. */ private class TextWatcherDelegator implements TextWatcher { + @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { if (!mIsSettingTextFromJS && mListeners != null) {