Skip to content

Commit

Permalink
fix(Android): Restore focus on page transitions (#2640)
Browse files Browse the repository at this point in the history
## 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)
  • Loading branch information
micheleb authored Jan 23, 2025
1 parent 9d9e797 commit c0b5586
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,11 @@ class ScreenStackFragment :
screen.background = shape
}

override fun onStart() {
lastFocusedChild?.requestFocus()
super.onStart()
}

override fun onStop() {
if (DeviceUtils.isPlatformAndroidTV(context)) {
lastFocusedChild = findLastFocusedChild()
Expand Down

0 comments on commit c0b5586

Please sign in to comment.