0

The title is pretty much the gist of the issue. I am designing an onboarding flow in which every page contained within has a TextInputField that requests focus upon first composition.

Using animateScrollToPage() in this scenario leads to unexpected behaviour: pages not being scrolled all the way or pages being skipped entirely. Removing the focus requesting or using scrollToPage() instead of animateScrollToPage() fixes the issues.

This behaviour is easy to reproduce on both the deprecated Accompanist Pager and the one introduced into foundation since 1.4.0.

I was wondering if anyone has a potential solution to this issue or if it is just an inherent issue of Compose. Any suggestions/opinions are appreciated. Thanks!

V Mircan
  • 203
  • 5
  • 13
  • 2
    You can check if currentPageOffset is zero before requesting focus and current page. You can refer [this answer](https://stackoverflow.com/questions/76182265/how-can-i-handle-with-multiple-textfield-focus-in-jetpack-compose-pager/76183955#76183955) for working demo. – Thracian May 18 '23 at 14:04
  • @Thracian Thanks a lot! I managed to get it to work. Honestly didn't think to manually check for the settled state of the pager. Please feel free to post it as an answer and I'll mark it as accepted. – V Mircan May 18 '23 at 14:36

0 Answers0