From 8a3cc6411e497bae04ee73229ba5e68f87d20fcd Mon Sep 17 00:00:00 2001 From: Eric Rozell Date: Wed, 29 Oct 2025 16:18:32 -0700 Subject: [PATCH] Remove unnecessary local variable in for deferred focus (#54326) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/54326 This variable was not needed, isAttachedToWindow was working as expected. ## Changelog [Internal] Reviewed By: Abbondanzo Differential Revision: D85798355 fbshipit-source-id: 1716b323b4ac0d1d6f3e29370223db66540020d2 --- .../java/com/facebook/react/views/view/ReactViewGroup.kt | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.kt index c5338378be5..6147dd2e348 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.kt @@ -154,7 +154,6 @@ public open class ReactViewGroup public constructor(context: Context?) : AccessibilityManager.AccessibilityStateChangeListener? = null private var focusOnAttach = false - private var hasAttachedToWindowForFocus = false init { initView() @@ -217,7 +216,6 @@ public open class ReactViewGroup public constructor(context: Context?) : // In case a focus was attempted but the view never attached, reset to false focusOnAttach = false - hasAttachedToWindowForFocus = false } private var _drawingOrderHelper: ViewGroupDrawingOrderHelper? = null @@ -423,9 +421,7 @@ public open class ReactViewGroup public constructor(context: Context?) : } internal fun requestFocusFromJS() { - // We need a local variable here as opposed to the View.isAttachedToWindow check - // since the value is not updated until after the Fabric commit. - if (hasAttachedToWindowForFocus) { + if (isAttachedToWindow) { super.requestFocus(FOCUS_DOWN, null) } else { focusOnAttach = true @@ -586,7 +582,6 @@ public open class ReactViewGroup public constructor(context: Context?) : updateClippingRect() } - hasAttachedToWindowForFocus = true if (focusOnAttach) { requestFocusFromJS() focusOnAttach = false