Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onLayoutChildren resets the current scroll offset and changes the scroll position #83

Open
Maxr1998 opened this issue Nov 5, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@Maxr1998
Copy link
Contributor

Maxr1998 commented Nov 5, 2023

  • Device: Samsung Z Fold 4
  • OS Version: Android 13, OneUI 5.1
  • Project Version: latest git

🐛 Describe

When onLayoutChildren is called at a non-zero scroll offset, e.g., by a call to Adapter.notifyItemRangeChanged(0, size), the scroll offset will be reset to zero.

🐌 Steps to reproduce

  1. Have a list of elements and scroll a bit to make a view partially visible.
  2. Call notifyItemRangeChanged(0, size) on the adapter, and observe onLayoutChildren being called again.
  3. The current scroll position will be reset, to a random (near?) item which is aligned with the RecyclerView again – the scroll offset of the first visible view is zero.

🦋 Expected behavior

The scroll position should be kept. Compare RecyclerView's built-in LinearLayoutManager, which shows this behavior.

🐝 Requested assignment

I would love to fix this myself, but with the complexity of the RecyclerView library and a lack of knowledge and time on my side, I won't be able to fix this myself.

@Maxr1998 Maxr1998 added the bug Something isn't working label Nov 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant