Skip to content

Back out "Fix issue where text inputs cannot blur on <= Android 8.1" #51336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -6553,7 +6553,6 @@ public class com/facebook/react/views/textinput/ReactEditText : androidx/appcomp
public fun onTextContextMenuItem (I)Z
public fun onTouchEvent (Landroid/view/MotionEvent;)Z
public fun removeTextChangedListener (Landroid/text/TextWatcher;)V
public fun requestFocus (ILandroid/graphics/Rect;)Z
public final fun requestFocusFromJS ()V
public final fun setAllowFontScaling (Z)V
public final fun setAutoFocus (Z)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,23 +364,9 @@ public open class ReactEditText public constructor(context: Context) : AppCompat
hideSoftKeyboard()
}

override fun requestFocus(direction: Int, previouslyFocusedRect: Rect?): Boolean {
// On some older versions of Android there is a bug where `clearFocus` will try to focus the
// first focusable View in the hierarchy after clearing focus. This is intended behavior, but
// only if you are not in touch mode per
// https://developer.android.com/reference/android/view/View#clearFocus(), yet this happens in
// both. Therefore, we are swallowing Android-based focus calls if we are in touch mode.
// If we are not in touch mode (using a hardware keyboard) then we will allow this to happen.
// Note this only happens for Android-origin focus calls, as opposed to JS-origin (like tapping)
// since those go through `requestFocusProgrammatically`
if (isInTouchMode) {
return isFocused
}
return super.requestFocus(direction, previouslyFocusedRect)
}

// For cases like autoFocus, or ref.focus() where we request focus programmatically and not
// through interacting with the EditText directly (like clicking on it). We cannot use stock
// through
// interacting with the EditText directly (like clicking on it). We cannot use stock
// requestFocus() because it will not pop up the soft keyboard, only clicking the input will do
// that. This method will eventually replace requestFocusInternal()
private fun requestFocusProgrammatically(): Boolean {
Expand Down
Loading