I have a “looped” `HorizontalPager` . The looping was achieved by setting the capacity of the list ...
f
I have a “looped”
HorizontalPager
. The looping was achieved by setting the capacity of the list as
Int.MAX_SIZE
but then when testing the app using keyboard and moving the focus to the items below this list, the app crashes with an ANR. The same thing happens with a normal list ( not a
horizontalPager
). Anyone has any idea about what the issue could be ?
m
are you using
HorizontalPagerIndicator
?
f
no
weird thing is that it also happens with normal lists and only happens when using keyboard. I only noticed this when testing the accessability of the app and had to use the keyboard
s
Hm, that sounds like a bug with focus search. The case with Int.MAX_VALUE is the intended way of achieving this behavior. Please file an issue!
f
issue created, thank you 👍
s
Can you share the link to the issue, couldn't find it on the bug tracker 🙂
f
there was already another one, so i just commented on it as it was created by another teammate. https://issuetracker.google.com/u/2/issues/271327271
i added your quote in there because i thought it could help someone solving the issue
r
Can you help me create a small repro to debug this? I don't see the issue with this code:
Copy code
LazyRow(modifier = Modifier.size(200.dp)) {
    items(Int.MAX_VALUE) {
        FocusableText("${it % 5}")
    }
}
where FocuableText is
Copy code
@Composable
fun FocusableText(text: String) {
    var color by remember { mutableStateOf(Black) }
    Text(
        modifier = Modifier
            .onFocusChanged { color = if (it.isFocused) Green else Black }
            .focusable()
        text = text,
        color = color
    )
}
Can you please add the stack trace to the bug too?
p
Hello! Ralston, I've responded to this on the issue page. Its about changing focus from inside the infinite list to another composable below it or above it (that is outside), not about focusing on the infinite list items.
f
yeah it is about moving to the items below using the keyboard