Pager in 0.19.0 reporting `currentPage` as 0 which is wrong.
See original GitHub issueDescribe the bug
In some situations, this line will cause problems. For some unknown reasons, the currentLayoutPageInfo
would become null and the current page is set to 0 while it was a non-zero value a couple milliseconds ago.
To Reproduce
Steps to reproduce the behavior:
I’ll attach a composable file for you. What I’m doing here is syncing the pager at the top with the horizontal row at the bottom. This code works as expected on 0.18.0. But even after changing the deprecated functions and stuff, the currentPage
is reported as 0 right after being the correct value. You can try scrolling the pager and see the weird selection behavior for the ThumbnailsRow.
Expected behavior
The code I attached is working as expected on 0.18.0.
Environment:
- Android OS version: I tested on Android 12
- Device: Emulator, Pixel 5a
- Accompanist version: 0.19.0
Additional context
Check out the line with Log.d("Compose", "$selectedIndex")
. When used in Preview, the problem may not show up. In an application, it does show up more.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:7
- Comments:6 (1 by maintainers)
I also stumbled upon this as is completely breaks the Pager Indicator Component. One thing to note: it seem the issue only appears if you set
itemSpacing
to a value >0.Please try to use the latest version (0.20.3 if you are on Compose 1.0) and file a new bug if you still see it