Skip to content

Commit e00028f

Browse files
joevilchesfacebook-github-bot
authored andcommitted
Clean up useEditTextStockAndroidFocusBehavior feature flag (#51039)
Summary: Pull Request resolved: #51039 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 Reviewed By: NickGerleman Differential Revision: D73954790 fbshipit-source-id: 4682cf709aa2f34ba69e76a35d07a908edb28f23
1 parent 6fa1864 commit e00028f

22 files changed

Lines changed: 30 additions & 189 deletions

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6600,7 +6600,6 @@ public class com/facebook/react/views/textinput/ReactEditText : androidx/appcomp
66006600
public fun onTextContextMenuItem (I)Z
66016601
public fun onTouchEvent (Landroid/view/MotionEvent;)Z
66026602
public fun removeTextChangedListener (Landroid/text/TextWatcher;)V
6603-
public fun requestFocus (ILandroid/graphics/Rect;)Z
66046603
public final fun requestFocusFromJS ()V
66056604
public final fun setAllowFontScaling (Z)V
66066605
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<<991cfdadfc26e470da425a986d75c766>>
7+
* @generated SignedSource<<b86b8bb1d53ca03240c25adb8b423040>>
88
*/
99

1010
/**
@@ -258,12 +258,6 @@ public object ReactNativeFeatureFlags {
258258
@JvmStatic
259259
public fun useAlwaysAvailableJSErrorHandling(): Boolean = accessor.useAlwaysAvailableJSErrorHandling()
260260

261-
/**
262-
* If true, focusing in ReactEditText will mainly use stock Android requestFocus() behavior. If false it will use legacy custom focus behavior.
263-
*/
264-
@JvmStatic
265-
public fun useEditTextStockAndroidFocusBehavior(): Boolean = accessor.useEditTextStockAndroidFocusBehavior()
266-
267261
/**
268262
* 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.
269263
*/

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<<65268cf15face782370694a2a5bd8c3f>>
7+
* @generated SignedSource<<9c1e0e7e87aead96e2554ef5ecf9e7af>>
88
*/
99

1010
/**
@@ -58,7 +58,6 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
5858
private var traceTurboModulePromiseRejectionsOnAndroidCache: Boolean? = null
5959
private var updateRuntimeShadowNodeReferencesOnCommitCache: Boolean? = null
6060
private var useAlwaysAvailableJSErrorHandlingCache: Boolean? = null
61-
private var useEditTextStockAndroidFocusBehaviorCache: Boolean? = null
6261
private var useFabricInteropCache: Boolean? = null
6362
private var useNativeViewConfigsInBridgelessModeCache: Boolean? = null
6463
private var useOptimizedEventBatchingOnAndroidCache: Boolean? = null
@@ -409,15 +408,6 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
409408
return cached
410409
}
411410

412-
override fun useEditTextStockAndroidFocusBehavior(): Boolean {
413-
var cached = useEditTextStockAndroidFocusBehaviorCache
414-
if (cached == null) {
415-
cached = ReactNativeFeatureFlagsCxxInterop.useEditTextStockAndroidFocusBehavior()
416-
useEditTextStockAndroidFocusBehaviorCache = cached
417-
}
418-
return cached
419-
}
420-
421411
override fun useFabricInterop(): Boolean {
422412
var cached = useFabricInteropCache
423413
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<<6650ca57c9b43c16506ea8a95cf95b8a>>
7+
* @generated SignedSource<<b95c0d1f576b67fcf9d9df498ea30994>>
88
*/
99

1010
/**
@@ -104,8 +104,6 @@ public object ReactNativeFeatureFlagsCxxInterop {
104104

105105
@DoNotStrip @JvmStatic public external fun useAlwaysAvailableJSErrorHandling(): Boolean
106106

107-
@DoNotStrip @JvmStatic public external fun useEditTextStockAndroidFocusBehavior(): Boolean
108-
109107
@DoNotStrip @JvmStatic public external fun useFabricInterop(): Boolean
110108

111109
@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<<906ab78c1c4099bc4711c102885becd0>>
7+
* @generated SignedSource<<c7425e6212e4e9d70e64452e550bf638>>
88
*/
99

1010
/**
@@ -99,8 +99,6 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
9999

100100
override fun useAlwaysAvailableJSErrorHandling(): Boolean = false
101101

102-
override fun useEditTextStockAndroidFocusBehavior(): Boolean = true
103-
104102
override fun useFabricInterop(): Boolean = true
105103

106104
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<<aa86a9c0807638f1f44ced69462b1d17>>
7+
* @generated SignedSource<<5b145ee103cf6b40e13d33c88cd52777>>
88
*/
99

1010
/**
@@ -62,7 +62,6 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
6262
private var traceTurboModulePromiseRejectionsOnAndroidCache: Boolean? = null
6363
private var updateRuntimeShadowNodeReferencesOnCommitCache: Boolean? = null
6464
private var useAlwaysAvailableJSErrorHandlingCache: Boolean? = null
65-
private var useEditTextStockAndroidFocusBehaviorCache: Boolean? = null
6665
private var useFabricInteropCache: Boolean? = null
6766
private var useNativeViewConfigsInBridgelessModeCache: Boolean? = null
6867
private var useOptimizedEventBatchingOnAndroidCache: Boolean? = null
@@ -451,16 +450,6 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
451450
return cached
452451
}
453452

454-
override fun useEditTextStockAndroidFocusBehavior(): Boolean {
455-
var cached = useEditTextStockAndroidFocusBehaviorCache
456-
if (cached == null) {
457-
cached = currentProvider.useEditTextStockAndroidFocusBehavior()
458-
accessedFeatureFlags.add("useEditTextStockAndroidFocusBehavior")
459-
useEditTextStockAndroidFocusBehaviorCache = cached
460-
}
461-
return cached
462-
}
463-
464453
override fun useFabricInterop(): Boolean {
465454
var cached = useFabricInteropCache
466455
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<<bad6f4d9b4c7ba419c2ad37a5089c3e7>>
7+
* @generated SignedSource<<9cdb965a420d53cf36b6531684cb07ae>>
88
*/
99

1010
/**
@@ -99,8 +99,6 @@ public interface ReactNativeFeatureFlagsProvider {
9999

100100
@DoNotStrip public fun useAlwaysAvailableJSErrorHandling(): Boolean
101101

102-
@DoNotStrip public fun useEditTextStockAndroidFocusBehavior(): Boolean
103-
104102
@DoNotStrip public fun useFabricInterop(): Boolean
105103

106104
@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<<65232e117b548982fd5c59502599b1bb>>
7+
* @generated SignedSource<<c89831646046b10c7b2a40e14deb3d1a>>
88
*/
99

1010
/**
@@ -267,12 +267,6 @@ class ReactNativeFeatureFlagsJavaProvider
267267
return method(javaProvider_);
268268
}
269269

270-
bool useEditTextStockAndroidFocusBehavior() override {
271-
static const auto method =
272-
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("useEditTextStockAndroidFocusBehavior");
273-
return method(javaProvider_);
274-
}
275-
276270
bool useFabricInterop() override {
277271
static const auto method =
278272
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("useFabricInterop");
@@ -509,11 +503,6 @@ bool JReactNativeFeatureFlagsCxxInterop::useAlwaysAvailableJSErrorHandling(
509503
return ReactNativeFeatureFlags::useAlwaysAvailableJSErrorHandling();
510504
}
511505

512-
bool JReactNativeFeatureFlagsCxxInterop::useEditTextStockAndroidFocusBehavior(
513-
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
514-
return ReactNativeFeatureFlags::useEditTextStockAndroidFocusBehavior();
515-
}
516-
517506
bool JReactNativeFeatureFlagsCxxInterop::useFabricInterop(
518507
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
519508
return ReactNativeFeatureFlags::useFabricInterop();
@@ -694,9 +683,6 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
694683
makeNativeMethod(
695684
"useAlwaysAvailableJSErrorHandling",
696685
JReactNativeFeatureFlagsCxxInterop::useAlwaysAvailableJSErrorHandling),
697-
makeNativeMethod(
698-
"useEditTextStockAndroidFocusBehavior",
699-
JReactNativeFeatureFlagsCxxInterop::useEditTextStockAndroidFocusBehavior),
700686
makeNativeMethod(
701687
"useFabricInterop",
702688
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<<980b6545944b8053fbe9901d3e4746ee>>
7+
* @generated SignedSource<<2a5ad62d2cb4f1111391f1b566e10c1d>>
88
*/
99

1010
/**
@@ -144,9 +144,6 @@ class JReactNativeFeatureFlagsCxxInterop
144144
static bool useAlwaysAvailableJSErrorHandling(
145145
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
146146

147-
static bool useEditTextStockAndroidFocusBehavior(
148-
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
149-
150147
static bool useFabricInterop(
151148
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
152149

0 commit comments

Comments
 (0)