lists: measure a card, not the header, for cards-per-row

LEFT from any card of a grid's first row opened the menu drawer. The
cells-per-row estimate read the width of the first visible grid item,
but near the top that is the page header, which spans the whole width —
so it computed one card per row and treated every card as a row start.
Skip full-span items when estimating; row starts resolve correctly even
while the header is on screen.
This commit is contained in:
Jeena 2026-10-13 23:17:03 +00:00
parent 710a0f23cc
commit ec2b1f03b1

View file

@ -93,10 +93,15 @@ fun VideoListScreen(
// Cards-per-row of the adaptive grid — LEFT from the first card of ANY row // Cards-per-row of the adaptive grid — LEFT from the first card of ANY row
// must open the drawer (issue #7: "every time I'm all the way on the left"). // must open the drawer (issue #7: "every time I'm all the way on the left").
// Measure a CARD, not the first visible item: the page header spans the full
// width, and reading its width made cards-per-row = 1 — every card near the
// top then thought it was a row start and opened the drawer.
val cellsPerRow by remember { val cellsPerRow by remember {
androidx.compose.runtime.derivedStateOf { androidx.compose.runtime.derivedStateOf {
val info = gridState.layoutInfo val info = gridState.layoutInfo
val w = info.visibleItemsInfo.firstOrNull()?.size?.width ?: 0 val w = info.visibleItemsInfo
.firstOrNull { it.size.width < info.viewportSize.width }
?.size?.width ?: 0
if (w > 0) (info.viewportSize.width / w).coerceIn(1, 10) else 0 if (w > 0) (info.viewportSize.width / w).coerceIn(1, 10) else 0
} }
} }