Status Update
Comments
rv...@google.com <rv...@google.com> #2
Thanks for the report. Able to reproduce with the following code:
Column(
modifier = Modifier
.fillMaxSize()
.background(Color.Red)
) {
Text(
text = "Header",
modifier = Modifier
.fillMaxWidth()
.height(100.dp)
.border(2.dp, Color.Green)
)
val contentPadding = 20.dp
TvLazyVerticalGrid(
columns = TvGridCells.Fixed(3),
horizontalArrangement = Arrangement.spacedBy(15.dp),
verticalArrangement = Arrangement.spacedBy(15.dp),
contentPadding = PaddingValues(contentPadding),
modifier = Modifier
.fillMaxWidth()
.weight(1f)
.border(2.dp, Color.Green)
) {
items((1..10).toList(), key = { it }) {
androidx.tv.material3.Card(
onClick = { },
modifier = Modifier.size(240.dp, 320.dp),
scale = CardScale.None,
) {
Text(text = "Item #$it")
}
}
}
}
The default PivotOffsets.parentFraction
is 0.3f
. Since the card's height is greater than 1 - 0.3f
, when bringing the item into view on focus, it is scrolled its entire height and the resultant PivotOffset.parentFraction
becomes less than the default 0.3f
.
This causes the Card's bottom to touch the container's bottom. Because of this, the cards below are not getting placed on the view and are hence not being considered for focus search.
When we debug through the false
because it is unable to find the next focusable node below the current focused item. On further investigation, it is observed that false
which calls a private function children.findBestCandidate
returns null which seems to be causing this issue. The candidateNode.isEligibleForFocusSearch
and it is returning false
for the nodes below the currently focused item. node.isPlaced
and node.isAttached
.
ap...@google.com <ap...@google.com> #3
Branch: androidx-main
commit f1dcd8643cf97fadb52684ee0d7d4132d7900694
Author: vinekumar <vinekumar@google.com>
Date: Thu Jul 13 22:08:46 2023
Sync the tv-foundation fork with compose-foundation
Adding in the changes from compose-foundation to tv-foundation.
Fixes: 287011882
Test: NA
Relnote: Sync tv-foundation fork with compose-foundation
Change-Id: I737c337d6ff7337d651aa0c0efa7acbee762fe7b
M tv/tv-foundation/api/api_lint.ignore
M tv/tv-foundation/api/current.txt
M tv/tv-foundation/api/restricted_current.txt
M tv/tv-foundation/build.gradle
M tv/tv-foundation/lint-baseline.xml
M tv/tv-foundation/src/androidTest/java/androidx/tv/foundation/lazy/grid/LazyGridAnimateItemPlacementTest.kt
M tv/tv-foundation/src/androidTest/java/androidx/tv/foundation/lazy/grid/LazyGridTest.kt
D tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/grid/ItemIndex.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/grid/LazyGrid.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/grid/LazyGridAnimateScrollScope.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/grid/LazyGridDsl.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/grid/LazyGridItemPlacementAnimator.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/grid/LazyGridItemProvider.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/grid/LazyGridMeasure.kt
A tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/grid/LazyGridMeasuredItem.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/grid/LazyGridMeasuredLine.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/grid/LazyGridScrollPosition.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/grid/LazyGridSpanLayoutProvider.kt
A tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/grid/LazyLayoutAnimateItemModifierNode.kt
D tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/grid/LazyMeasuredItem.kt
D tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/grid/LazyMeasuredItemProvider.kt
D tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/grid/LazyMeasuredLineProvider.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/grid/TvLazyGridItemInfo.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/grid/TvLazyGridItemScopeImpl.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/grid/TvLazyGridMeasureResult.kt
D tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/grid/TvLazyGridScopeImpl.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/grid/TvLazyGridState.kt
A tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/layout/AwaitFirstLayoutModifier.kt
A tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/layout/LazyLayoutBeyondBoundsInfo.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/layout/LazyLayoutKeyIndexMap.kt
A tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/layout/LazyLayoutNearestRangeState.kt
D tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/layout/LazyLayoutSemanticState.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/layout/LazyLayoutSemantics.kt
D tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/list/DataIndex.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/list/LazyBeyondBoundsModifier.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/list/LazyList.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/list/LazyListAnimateScrollScope.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/list/LazyListHeaders.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/list/LazyListItemPlacementAnimator.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/list/LazyListItemProvider.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/list/LazyListMeasure.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/list/LazyListMeasureResult.kt
A tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/list/LazyListMeasuredItem.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/list/LazyListMeasuredItemProvider.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/list/LazyListScrollPosition.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/list/LazyListState.kt
D tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/list/LazyMeasuredItem.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/list/TvLazyListItemInfo.kt
M tv/tv-foundation/src/main/java/androidx/tv/foundation/lazy/list/TvLazyListItemScopeImpl.kt
pr...@google.com <pr...@google.com> #4
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.tv:tv-foundation:1.0.0-alpha09
Description
Version used: 1.0.0-alpha07 / 1.0.0-alpha06
Devices/Android versions reproduced on: Sabrina (Android 12)
If this is a bug in the library, we would appreciate if you could attach:
- Sample project to trigger the issue.
```
@Preview
@Composable
fun TestLazyGrid() {
val cardSpacing = 20.dp
val contentPadding = 20.dp
TvLazyVerticalGrid(
columns = TvGridCells.Fixed(3),
horizontalArrangement = Arrangement.spacedBy(cardSpacing),
verticalArrangement = Arrangement.spacedBy(cardSpacing),
contentPadding = PaddingValues(contentPadding),
modifier = Modifier.fillMaxSize()
) {
// Tested on Sabrina
// val height = 357.dp // works fine, can scroll to the last item
val height = 358.dp // can't scroll past the 2nd row
items((1..12).toList()) {
Card(
onClick = { },
Modifier.size(240.dp, height)
) {
Text(text = "Item #$it")
}
}
}
}
```
Depending on the card sizes in the grid (357dp vs 358dp in the example above), scrolling will stop at the 2nd row.