https://kotlinlang.org logo
Title
a

axehit

03/25/2022, 11:04 AM
Hello, I am currently writing some tests for pagination in compose, and I noticed that
performScrollToIndex
method in compose ui test library provided for scrolling an item to a particular index, scroll that item index to the very top position. This behaviour is different from the
recyclerView.scrollToPosition
method we have currently in the old view system which scrolls the item just enough to make that item visible at the bottom. Can someone tell me is there an API for tests in compose to have that similar behaviour of scrolling the item just enough to make it visible at the bottom instead of at the top?
1
s

Stylianos Gakis

03/25/2022, 12:58 PM
BringIntoViewRequester
is a name that feels like it would fit this use case. Try it out. https://developer.android.com/reference/kotlin/androidx/compose/foundation/relocation/BringIntoViewRequester
a

axehit

03/25/2022, 7:28 PM
Thanks @Stylianos Gakis, this method might work during actual app view implementation. But I am looking for something similar for the tests. In tests, I can't modify the Modifier of a composable which I am scrolling, so need some API specifically for the tests that scroll a lazyColumn composable to the bottom, instead of top.
s

Stylianos Gakis

03/25/2022, 7:47 PM
Right, it’s specifically for tests. Sorry then I don’t think I have an idea of how to achieve this 🤷‍♂️
z

Zach Klippenstein (he/him) [MOD]

03/26/2022, 8:52 PM
I would suggest filing a feature request
👍 1
a

axehit

03/28/2022, 7:24 PM
Created a feature request here: https://issuetracker.google.com/issues/227218372
1