Skip to content

Commit c0b5586

Browse files
authored
fix(Android): Restore focus on page transitions (#2640)
## Description After #1894 was merged, a refactoring of the native source happened, and the call to `lastFocusedChild.requestFocus()` that happened on the overridden `onStart()` method in `ScreenStackFragment` got lost along the way, making focus disappear when popping a screen from the stack. Fixes #1706 ## Changes - Updated `ScreenStackFragment.kt`, resurrecting the old `onStart()` override (`lastFocusedChild` is only set on Android TV, so this change only affects that platform)
1 parent 9d9e797 commit c0b5586

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

android/src/main/java/com/swmansion/rnscreens/ScreenStackFragment.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,11 @@ class ScreenStackFragment :
478478
screen.background = shape
479479
}
480480

481+
override fun onStart() {
482+
lastFocusedChild?.requestFocus()
483+
super.onStart()
484+
}
485+
481486
override fun onStop() {
482487
if (DeviceUtils.isPlatformAndroidTV(context)) {
483488
lastFocusedChild = findLastFocusedChild()

0 commit comments

Comments
 (0)