Fix two home row focus bugs (#1376)

## Description
1. Fixes when moving from nav drawer to home page content, focus would
sometimes move up a row
2. Fixes when moving up/down between rows, focus would sometimes move to
the later card (usually the last visible)

The second above is fixed by downgrading `tv-material` to
`1.0.1-alpha01`. Switching to
[`1.0.1-beta01`](https://developer.android.com/jetpack/androidx/releases/tv#tv-material-1.1.0-beta01)
or newer causes the bug. Not clear if its a bug in the library or
Wholphin though.

### Related issues
Fixes #1359

### Testing
Emulator

## Screenshots
N/A

## AI or LLM usage
None
This commit is contained in:
Damontecres 2026-05-11 17:48:38 -04:00 committed by GitHub
parent 4928c1156d
commit 8b9b0ddec8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View file

@ -31,6 +31,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusProperties
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.focus.focusRestorer
import androidx.compose.ui.focus.onFocusChanged
@ -307,7 +308,15 @@ fun HomePageContent(
focusedItem?.let { onUpdateBackdrop.invoke(it) }
}
Box(modifier = modifier) {
Column(modifier = Modifier.fillMaxSize()) {
Column(
modifier =
Modifier
.focusProperties {
onEnter = {
rowFocusRequesters.getOrNull(currentPosition.row)?.tryRequestFocus()
}
}.fillMaxSize(),
) {
headerComposable.invoke(focusedItem)
val density = LocalDensity.current