From ec2b1f03b1904c9f352680ae7a96a1f7aea6d7c1 Mon Sep 17 00:00:00 2001 From: Jeena Date: Tue, 13 Oct 2026 23:17:03 +0000 Subject: [PATCH] lists: measure a card, not the header, for cards-per-row MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../net/jeena/jtubetv/ui/screens/list/VideoListScreen.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/net/jeena/jtubetv/ui/screens/list/VideoListScreen.kt b/app/src/main/java/net/jeena/jtubetv/ui/screens/list/VideoListScreen.kt index 17d7681..498025b 100644 --- a/app/src/main/java/net/jeena/jtubetv/ui/screens/list/VideoListScreen.kt +++ b/app/src/main/java/net/jeena/jtubetv/ui/screens/list/VideoListScreen.kt @@ -93,10 +93,15 @@ fun VideoListScreen( // 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"). + // 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 { androidx.compose.runtime.derivedStateOf { 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 } }