Skip to content

Commit bae448f

Browse files
joevilchesfacebook-github-bot
authored andcommitted
Clean up useEditTextStockAndroidFocusBehavior feature flag (facebook#51039)
Summary: We added a feature flag in case this broke things. Its been about 4 months now with now issues, I think we can clean this up. Changelog: [Android][Fixed] - Can now focus TextInput with keyboard Differential Revision: D73954790
1 parent 4d8eeb3 commit bae448f

22 files changed

+30
-189
lines changed

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6640,7 +6640,6 @@ public class com/facebook/react/views/textinput/ReactEditText : androidx/appcomp
66406640
public fun onTextContextMenuItem (I)Z
66416641
public fun onTouchEvent (Landroid/view/MotionEvent;)Z
66426642
public fun removeTextChangedListener (Landroid/text/TextWatcher;)V
6643-
public fun requestFocus (ILandroid/graphics/Rect;)Z
66446643
public final fun requestFocusFromJS ()V
66456644
public final fun setAllowFontScaling (Z)V
66466645
public final fun setAutoFocus (Z)V

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<1172f5f2fda3a7d7835f619376f65b3a>>
7+
* @generated SignedSource<<e4825c5d7bf9be219cf86f2578d2f802>>
88
*/
99

1010
/**
@@ -246,12 +246,6 @@ public object ReactNativeFeatureFlags {
246246
@JvmStatic
247247
public fun useAlwaysAvailableJSErrorHandling(): Boolean = accessor.useAlwaysAvailableJSErrorHandling()
248248

249-
/**
250-
* If true, focusing in ReactEditText will mainly use stock Android requestFocus() behavior. If false it will use legacy custom focus behavior.
251-
*/
252-
@JvmStatic
253-
public fun useEditTextStockAndroidFocusBehavior(): Boolean = accessor.useEditTextStockAndroidFocusBehavior()
254-
255249
/**
256250
* Should this application enable the Fabric Interop Layer for Android? If yes, the application will behave so that it can accept non-Fabric components and render them on Fabric. This toggle is controlling extra logic such as custom event dispatching that are needed for the Fabric Interop Layer to work correctly.
257251
*/

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<b045498e0c54e6c12cdf6a6dc25fd109>>
7+
* @generated SignedSource<<921d52cfcede957c99e142c677060267>>
88
*/
99

1010
/**
@@ -56,7 +56,6 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
5656
private var traceTurboModulePromiseRejectionsOnAndroidCache: Boolean? = null
5757
private var updateRuntimeShadowNodeReferencesOnCommitCache: Boolean? = null
5858
private var useAlwaysAvailableJSErrorHandlingCache: Boolean? = null
59-
private var useEditTextStockAndroidFocusBehaviorCache: Boolean? = null
6059
private var useFabricInteropCache: Boolean? = null
6160
private var useNativeViewConfigsInBridgelessModeCache: Boolean? = null
6261
private var useOptimizedEventBatchingOnAndroidCache: Boolean? = null
@@ -389,15 +388,6 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
389388
return cached
390389
}
391390

392-
override fun useEditTextStockAndroidFocusBehavior(): Boolean {
393-
var cached = useEditTextStockAndroidFocusBehaviorCache
394-
if (cached == null) {
395-
cached = ReactNativeFeatureFlagsCxxInterop.useEditTextStockAndroidFocusBehavior()
396-
useEditTextStockAndroidFocusBehaviorCache = cached
397-
}
398-
return cached
399-
}
400-
401391
override fun useFabricInterop(): Boolean {
402392
var cached = useFabricInteropCache
403393
if (cached == null) {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<007721988dfdf572f8ac218744341e60>>
7+
* @generated SignedSource<<740f29c1fcec976ea9bac59c966cc311>>
88
*/
99

1010
/**
@@ -100,8 +100,6 @@ public object ReactNativeFeatureFlagsCxxInterop {
100100

101101
@DoNotStrip @JvmStatic public external fun useAlwaysAvailableJSErrorHandling(): Boolean
102102

103-
@DoNotStrip @JvmStatic public external fun useEditTextStockAndroidFocusBehavior(): Boolean
104-
105103
@DoNotStrip @JvmStatic public external fun useFabricInterop(): Boolean
106104

107105
@DoNotStrip @JvmStatic public external fun useNativeViewConfigsInBridgelessMode(): Boolean

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<6b10c147b3f1753448f599ae4fb43387>>
7+
* @generated SignedSource<<b6561ef6b895414a107fa747935fbc2a>>
88
*/
99

1010
/**
@@ -95,8 +95,6 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
9595

9696
override fun useAlwaysAvailableJSErrorHandling(): Boolean = false
9797

98-
override fun useEditTextStockAndroidFocusBehavior(): Boolean = true
99-
10098
override fun useFabricInterop(): Boolean = true
10199

102100
override fun useNativeViewConfigsInBridgelessMode(): Boolean = false

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<b64966fc245f53645726747ec93a15d1>>
7+
* @generated SignedSource<<53de0b81080dd1418add34bfdc02ed88>>
88
*/
99

1010
/**
@@ -60,7 +60,6 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
6060
private var traceTurboModulePromiseRejectionsOnAndroidCache: Boolean? = null
6161
private var updateRuntimeShadowNodeReferencesOnCommitCache: Boolean? = null
6262
private var useAlwaysAvailableJSErrorHandlingCache: Boolean? = null
63-
private var useEditTextStockAndroidFocusBehaviorCache: Boolean? = null
6463
private var useFabricInteropCache: Boolean? = null
6564
private var useNativeViewConfigsInBridgelessModeCache: Boolean? = null
6665
private var useOptimizedEventBatchingOnAndroidCache: Boolean? = null
@@ -429,16 +428,6 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
429428
return cached
430429
}
431430

432-
override fun useEditTextStockAndroidFocusBehavior(): Boolean {
433-
var cached = useEditTextStockAndroidFocusBehaviorCache
434-
if (cached == null) {
435-
cached = currentProvider.useEditTextStockAndroidFocusBehavior()
436-
accessedFeatureFlags.add("useEditTextStockAndroidFocusBehavior")
437-
useEditTextStockAndroidFocusBehaviorCache = cached
438-
}
439-
return cached
440-
}
441-
442431
override fun useFabricInterop(): Boolean {
443432
var cached = useFabricInteropCache
444433
if (cached == null) {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<1e9beb93c98a0a82d030b7a3ea1cf7e4>>
7+
* @generated SignedSource<<b6abf91dbed6cebe36ea939afbf9d7fe>>
88
*/
99

1010
/**
@@ -95,8 +95,6 @@ public interface ReactNativeFeatureFlagsProvider {
9595

9696
@DoNotStrip public fun useAlwaysAvailableJSErrorHandling(): Boolean
9797

98-
@DoNotStrip public fun useEditTextStockAndroidFocusBehavior(): Boolean
99-
10098
@DoNotStrip public fun useFabricInterop(): Boolean
10199

102100
@DoNotStrip public fun useNativeViewConfigsInBridgelessMode(): Boolean

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.kt

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ import com.facebook.react.bridge.ReactSoftExceptionLogger.logSoftException
4747
import com.facebook.react.common.ReactConstants
4848
import com.facebook.react.common.build.ReactBuildConfig
4949
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
50-
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags.useEditTextStockAndroidFocusBehavior
5150
import com.facebook.react.internal.featureflags.ReactNativeNewArchitectureFeatureFlags
5251
import com.facebook.react.uimanager.BackgroundStyleApplicator.clipToPaddingBox
5352
import com.facebook.react.uimanager.BackgroundStyleApplicator.getBackgroundColor
@@ -198,10 +197,6 @@ public open class ReactEditText public constructor(context: Context) : AppCompat
198197
}
199198

200199
init {
201-
if (!useEditTextStockAndroidFocusBehavior()) {
202-
isFocusableInTouchMode = false
203-
}
204-
205200
inputMethodManager =
206201
context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
207202
defaultGravityHorizontal =
@@ -240,8 +235,7 @@ public open class ReactEditText public constructor(context: Context) : AppCompat
240235
// selection on accessibility click to undo that.
241236
setSelection(length)
242237
}
243-
return if (useEditTextStockAndroidFocusBehavior()) requestFocusProgrammatically()
244-
else requestFocusInternal()
238+
return requestFocusProgrammatically()
245239
}
246240
return super.performAccessibilityAction(host, action, args)
247241
}
@@ -366,38 +360,10 @@ public open class ReactEditText public constructor(context: Context) : AppCompat
366360
if (id == android.R.id.paste) android.R.id.pasteAsPlainText else id)
367361

368362
override fun clearFocus() {
369-
val useStockFocusBehavior = useEditTextStockAndroidFocusBehavior()
370-
if (!useStockFocusBehavior) {
371-
isFocusableInTouchMode = false
372-
}
373363
super.clearFocus()
374364
hideSoftKeyboard()
375365
}
376366

377-
override fun requestFocus(direction: Int, previouslyFocusedRect: Rect?): Boolean =
378-
// This is a no-op so that when the OS calls requestFocus(), nothing will happen.
379-
// ReactEditText
380-
// is a controlled component, which means its focus is controlled by JS, with two exceptions:
381-
// autofocus when it's attached to the window, and responding to accessibility events. In both
382-
// of these cases, we call requestFocusInternal() directly.
383-
if (useEditTextStockAndroidFocusBehavior()) {
384-
super.requestFocus(direction, previouslyFocusedRect)
385-
} else {
386-
isFocused
387-
}
388-
389-
private fun requestFocusInternal(): Boolean {
390-
isFocusableInTouchMode = true
391-
// We must explicitly call this method on the super class; if we call requestFocus() without
392-
// any arguments, it will call into the overridden requestFocus(int, Rect) above, which no-ops.
393-
val focused = super.requestFocus(FOCUS_DOWN, null)
394-
if (showSoftInputOnFocus) {
395-
showSoftKeyboard()
396-
}
397-
398-
return focused
399-
}
400-
401367
// For cases like autoFocus, or ref.focus() where we request focus programmatically and not
402368
// through
403369
// interacting with the EditText directly (like clicking on it). We cannot use stock
@@ -629,11 +595,7 @@ public open class ReactEditText public constructor(context: Context) : AppCompat
629595
}
630596

631597
public fun requestFocusFromJS() {
632-
if (useEditTextStockAndroidFocusBehavior()) {
633-
requestFocusProgrammatically()
634-
} else {
635-
requestFocusInternal()
636-
}
598+
requestFocusProgrammatically()
637599
}
638600

639601
internal fun clearFocusFromJS() {
@@ -983,11 +945,7 @@ public open class ReactEditText public constructor(context: Context) : AppCompat
983945
}
984946

985947
if (autoFocus && !didAttachToWindow) {
986-
if (useEditTextStockAndroidFocusBehavior()) {
987-
requestFocusProgrammatically()
988-
} else {
989-
requestFocusInternal()
990-
}
948+
requestFocusProgrammatically()
991949
}
992950

993951
didAttachToWindow = true

packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<ac6b60d9d2062eda500e291fb2167076>>
7+
* @generated SignedSource<<0fdc78dea868d9a0cb54784164fba4db>>
88
*/
99

1010
/**
@@ -255,12 +255,6 @@ class ReactNativeFeatureFlagsJavaProvider
255255
return method(javaProvider_);
256256
}
257257

258-
bool useEditTextStockAndroidFocusBehavior() override {
259-
static const auto method =
260-
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("useEditTextStockAndroidFocusBehavior");
261-
return method(javaProvider_);
262-
}
263-
264258
bool useFabricInterop() override {
265259
static const auto method =
266260
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("useFabricInterop");
@@ -487,11 +481,6 @@ bool JReactNativeFeatureFlagsCxxInterop::useAlwaysAvailableJSErrorHandling(
487481
return ReactNativeFeatureFlags::useAlwaysAvailableJSErrorHandling();
488482
}
489483

490-
bool JReactNativeFeatureFlagsCxxInterop::useEditTextStockAndroidFocusBehavior(
491-
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
492-
return ReactNativeFeatureFlags::useEditTextStockAndroidFocusBehavior();
493-
}
494-
495484
bool JReactNativeFeatureFlagsCxxInterop::useFabricInterop(
496485
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
497486
return ReactNativeFeatureFlags::useFabricInterop();
@@ -666,9 +655,6 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
666655
makeNativeMethod(
667656
"useAlwaysAvailableJSErrorHandling",
668657
JReactNativeFeatureFlagsCxxInterop::useAlwaysAvailableJSErrorHandling),
669-
makeNativeMethod(
670-
"useEditTextStockAndroidFocusBehavior",
671-
JReactNativeFeatureFlagsCxxInterop::useEditTextStockAndroidFocusBehavior),
672658
makeNativeMethod(
673659
"useFabricInterop",
674660
JReactNativeFeatureFlagsCxxInterop::useFabricInterop),

packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<e1f86665fe4df2f2ee9fb82261760a69>>
7+
* @generated SignedSource<<e42c45aad66631e44c01fad16bf21bc6>>
88
*/
99

1010
/**
@@ -138,9 +138,6 @@ class JReactNativeFeatureFlagsCxxInterop
138138
static bool useAlwaysAvailableJSErrorHandling(
139139
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
140140

141-
static bool useEditTextStockAndroidFocusBehavior(
142-
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
143-
144141
static bool useFabricInterop(
145142
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
146143

0 commit comments

Comments
 (0)