Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Fixed ScrollY when ItemsSource reloaded or row height changed #12047

Closed
wants to merge 19 commits into from

Conversation

rihadavid
Copy link

@rihadavid rihadavid commented Sep 7, 2020

EDIT: seems like I did some bad branching here, sorry, my first PR here 😁 this was supposed to be a single file commit (Xamarin.Forms.Platform.Android/Renderers/ListViewRenderer.cs). Can someone make it right?

Fixes two issues with ListView scroll event ScrollY value that were making it pretty unreliable and buggy.

Original code was commited in this commit

I'm not 100% sure if there can't be any other situation when the scroll fails to be tracked (maybe some fast scroll?), for which setting the _contentOffset to 0 might not be correct, but it fixes the "reloaded ItemsSource" issue, which seems to be the most common. When we are not able to track the offset at all, it's a bug anyway, so setting the offset to 0 seems good because it solves this issue at least.

Issues Resolved

API Changes

None

Platforms Affected

  • Android

Behavioral/Visual Changes

ScrollY value in Scrolled event might sometimes be different than before, because it's now fixed.

Testing Procedure

I tested the sample project in #8305 and #9370 and confirmed it is fixed. However, it might be good to test that setting the _contentOffset to 0 doesn't create any side effects in different situations.

PR Checklist

  • Targets the correct branch
  • Tests are passing (or failures are unrelated)

samhouts and others added 19 commits July 29, 2020 18:41
* [Build] Add auto-format daily action

* Update dotnet-format-daily.yml
* Added LineBreakMode in the Button and TestAttributes

* Added LineBreakMode implementation on Android platform

* Added Issue into the Controls project

* Removed unused method

* Added UWP support for LineBreakMode

* Implemented LineBreakMode on iOS

* Update Xamarin.Forms.Core/Button.cs

Co-authored-by: Stephane Delcroix <[email protected]>

Co-authored-by: Stephane Delcroix <[email protected]>
Co-authored-by: Rui Marinho <[email protected]>

fixes xamarin#3106
Fixes xamarin#8305 and xamarin#9370 and another bug that has not been reported - changing height of the first row also creates incorrect ScrollY value.
Not 100% sure if there can't be any other situation when the scroll fails to be tracked, for which setting the  `_contentOffset` to `0` might not be correct, but it fixes the "reloaded ItemsSource" issue, which seems to be the most common. When we were not able to track the offset at all, it's a bug anyway, so setting the offset to 0 seems good because it solves this issue at least.
@dnfadmin
Copy link

dnfadmin commented Sep 7, 2020

CLA assistant check
All CLA requirements met.

@pictos
Copy link
Contributor

pictos commented Sep 7, 2020

Hey @rihadavid thanks for your contribution! Try to rebase your branch against the 5.0.0. If you need any help, please let me know

@rihadavid
Copy link
Author

I did that, in the web GUI, but it didn't change the pull request. I am not friend with git commands, so it might be easier to close this and create a new PR, right?

@pictos
Copy link
Contributor

pictos commented Sep 7, 2020

@rihadavid if you don't want to try you can open a new. Be aware to create a branch based on the 5.0 branch

@rihadavid
Copy link
Author

Closing due to bad branching, moved to #12053

@rihadavid rihadavid closed this Sep 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
7 participants