Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Fix crash on ReactEditText with AppCompat 1.4.0
Browse files Browse the repository at this point in the history
Summary:
This Diff fixes a crash happening as the user uses AppCompat 1.4.0
as a dependency in their App and uses a `TextInput` component.

The crash happens as `mFabricViewStateManager` is accessed during
the ctor of the superclass, and is not yet initialized.

Fixes facebook#31572

Changelog:
[Android] [Fixed] - Fix crash on ReactEditText with AppCompat 1.4.0

Reviewed By: ShikaSD

Differential Revision: D32674975

fbshipit-source-id: efa413f5e33527a29fbcfa729e8b006ecb235978

# Conflicts:
#	ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java
  • Loading branch information
cortinico authored and adrianha committed Sep 19, 2022
1 parent 3381295 commit cbdc383
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
* A wrapper around the EditText that lets us better control what happens when an EditText gets
* focused or blurred, and when to display the soft keyboard and when not to.
*
* <p>ReactEditTexts have setFocusableInTouchMode set to false automatically because touches on the
* <p>ReactEditTexts have setFocusableInTouchMoactde set to false automatically because touches on the
* EditText are managed on the JS side. This also removes the nasty side effect that EditTexts have,
* which is that focus is always maintained on one of the EditTexts.
*
Expand Down Expand Up @@ -113,7 +113,8 @@ public class ReactEditText extends AppCompatEditText

private ReactViewBackgroundManager mReactBackgroundManager;

private final FabricViewStateManager mFabricViewStateManager = new FabricViewStateManager();
private final @Nullable FabricViewStateManager mFabricViewStateManager =
new FabricViewStateManager();
protected boolean mDisableTextDiffing = false;

protected boolean mIsSettingTextFromState = false;
Expand Down Expand Up @@ -733,8 +734,11 @@ private void setIntrinsicContentSize() {
// wrapper 100% of the time.
// Since the LocalData object is constructed by getting values from the underlying EditText
// view, we don't need to construct one or apply it at all - it provides no use in Fabric.
if (!mFabricViewStateManager.hasStateWrapper()) {
ReactContext reactContext = getReactContext(this);
ReactContext reactContext = getReactContext(this);

if (mFabricViewStateManager != null
&& !mFabricViewStateManager.hasStateWrapper()
&& !reactContext.isBridgeless()) {
final ReactTextInputLocalData localData = new ReactTextInputLocalData(this);
UIManagerModule uiManager = reactContext.getNativeModule(UIManagerModule.class);
if (uiManager != null) {
Expand Down Expand Up @@ -968,7 +972,7 @@ public FabricViewStateManager getFabricViewStateManager() {
*/
private void updateCachedSpannable(boolean resetStyles) {
// Noops in non-Fabric
if (!mFabricViewStateManager.hasStateWrapper()) {
if (mFabricViewStateManager != null && !mFabricViewStateManager.hasStateWrapper()) {
return;
}
// If this view doesn't have an ID yet, we don't have a cache key, so bail here
Expand Down

0 comments on commit cbdc383

Please sign in to comment.