From c55b4753a9d203821c67f71e0edbe2078626c9bd Mon Sep 17 00:00:00 2001 From: Joao Paulo Costa Marra Date: Tue, 28 Jul 2026 11:02:11 -0300 Subject: [PATCH 1/2] fix(android): use propagation view surface id --- .../listeners/FocusedInputObserver.kt | 2 +- .../listeners/FocusedInputObserverTest.kt | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 android/src/test/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserverTest.kt diff --git a/android/src/main/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserver.kt b/android/src/main/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserver.kt index 4f674044e8..637756bf63 100644 --- a/android/src/main/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserver.kt +++ b/android/src/main/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserver.kt @@ -43,7 +43,7 @@ class FocusedInputObserver( private val context: ThemedReactContext?, ) { // constructor variables - private val surfaceId = UIManagerHelper.getSurfaceId(view) + internal val surfaceId = UIManagerHelper.getSurfaceId(eventPropagationView) // state variables private var lastFocusedInput: EditText? = null diff --git a/android/src/test/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserverTest.kt b/android/src/test/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserverTest.kt new file mode 100644 index 0000000000..2449f0be50 --- /dev/null +++ b/android/src/test/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserverTest.kt @@ -0,0 +1,37 @@ +package com.reactnativekeyboardcontroller.listeners + +import android.content.Context +import android.view.View +import androidx.test.core.app.ApplicationProvider +import com.facebook.react.bridge.BridgeReactContext +import com.facebook.react.uimanager.ThemedReactContext +import com.facebook.react.views.view.ReactViewGroup +import org.junit.Assert.assertEquals +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner + +@RunWith(RobolectricTestRunner::class) +class FocusedInputObserverTest { + @Test + fun `uses event propagation view surface ID`() { + val context = ApplicationProvider.getApplicationContext() + val reactApplicationContext = BridgeReactContext(context) + val themedReactContext = ThemedReactContext(reactApplicationContext, context, "test", SURFACE_ID) + val modalRootView = View(context) + val eventPropagationView = + ReactViewGroup(themedReactContext).apply { + id = FABRIC_VIEW_ID + } + val observer = FocusedInputObserver(modalRootView, eventPropagationView, themedReactContext) + + assertEquals(SURFACE_ID, observer.surfaceId) + + observer.destroy() + } + + private companion object { + const val FABRIC_VIEW_ID = 2 + const val SURFACE_ID = 42 + } +} From 15bdb4fef1ede87c814ed8256dbae9a11920f4c2 Mon Sep 17 00:00:00 2001 From: Joao Paulo Costa Marra Date: Wed, 5 Aug 2026 06:56:21 -0300 Subject: [PATCH 2/2] fix(android): address modal surface ID review - Keep the propagation surface ID implementation private\n- Remove the over-engineered observer unit test --- .../listeners/FocusedInputObserver.kt | 2 +- .../listeners/FocusedInputObserverTest.kt | 37 ------------------- 2 files changed, 1 insertion(+), 38 deletions(-) delete mode 100644 android/src/test/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserverTest.kt diff --git a/android/src/main/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserver.kt b/android/src/main/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserver.kt index 637756bf63..ca6927ad0a 100644 --- a/android/src/main/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserver.kt +++ b/android/src/main/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserver.kt @@ -43,7 +43,7 @@ class FocusedInputObserver( private val context: ThemedReactContext?, ) { // constructor variables - internal val surfaceId = UIManagerHelper.getSurfaceId(eventPropagationView) + private val surfaceId = UIManagerHelper.getSurfaceId(eventPropagationView) // state variables private var lastFocusedInput: EditText? = null diff --git a/android/src/test/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserverTest.kt b/android/src/test/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserverTest.kt deleted file mode 100644 index 2449f0be50..0000000000 --- a/android/src/test/java/com/reactnativekeyboardcontroller/listeners/FocusedInputObserverTest.kt +++ /dev/null @@ -1,37 +0,0 @@ -package com.reactnativekeyboardcontroller.listeners - -import android.content.Context -import android.view.View -import androidx.test.core.app.ApplicationProvider -import com.facebook.react.bridge.BridgeReactContext -import com.facebook.react.uimanager.ThemedReactContext -import com.facebook.react.views.view.ReactViewGroup -import org.junit.Assert.assertEquals -import org.junit.Test -import org.junit.runner.RunWith -import org.robolectric.RobolectricTestRunner - -@RunWith(RobolectricTestRunner::class) -class FocusedInputObserverTest { - @Test - fun `uses event propagation view surface ID`() { - val context = ApplicationProvider.getApplicationContext() - val reactApplicationContext = BridgeReactContext(context) - val themedReactContext = ThemedReactContext(reactApplicationContext, context, "test", SURFACE_ID) - val modalRootView = View(context) - val eventPropagationView = - ReactViewGroup(themedReactContext).apply { - id = FABRIC_VIEW_ID - } - val observer = FocusedInputObserver(modalRootView, eventPropagationView, themedReactContext) - - assertEquals(SURFACE_ID, observer.surfaceId) - - observer.destroy() - } - - private companion object { - const val FABRIC_VIEW_ID = 2 - const val SURFACE_ID = 42 - } -}