I might have potentially found a bug in `LazyListM...
# compose
c
I might have potentially found a bug in
LazyListMeasure
but wanted to confirm this may be expected functionality before filing it. I currently need to observe the indexes of
LazyListItemInfo
from my LazyListState and use them to key off of. When entering my screen for the first time, I would expect that that list would hold the list of visible items except their indexes are off. The first position of the list returned has index
1
when I think it should be
0
. If I scroll up at all (it doesn't change the scroll visibly but I assume it causes measure to hit again and then add index of 0) Is this expected functionality? Line #s in 🧵
In LazyListMeasure's
measureLazyList
function lines 138-153 (Currently on 1.1.0-beta02)
Copy code
// then composing visible items forward until we fill the whole viewport
while (mainAxisUsed <= maxMainAxis && index.value < itemsCount) {
    val measuredItem = itemProvider.getAndMeasure(index)
    mainAxisUsed += measuredItem.sizeWithSpacings

    if (mainAxisUsed <= minOffset) {
        // this item is offscreen and will not be placed. advance firstVisibleItemIndex
        currentFirstItemIndex = index + 1
        currentFirstItemScrollOffset -= measuredItem.sizeWithSpacings
    } else {
        maxCrossAxis = maxOf(maxCrossAxis, measuredItem.crossAxisSize)
        visibleItems.add(measuredItem)
    }

    index++
}
Debugging through the launch of my screen, index at this point is 0 and mainAxisUsed is 0. It goes into the while and hits the first if, incrementing the index. Even though the first item index should probably be 0
a
is it possible that your first item has 0 height when it happens for you? I don’t think there is an issue in the code you mentioned. if you come up with a repro sample we can explore it
c
Ah! Something you said made me go back into a custom composable I had made for pagination. In there I was creating a Header composable (Although it was empty). I guess that ended up somehow taking up space causing the index to get incremented. That's wild. Thank you for responding = ) Making it conditional solved my issue 👍
👍 1