Fix [iOS]VerticalOffset Not Reset to Zero After Clearing ItemSource in CollectionView#26818
Closed
devanathan-vaithiyanathan wants to merge 6 commits intodotnet:mainfrom
Closed
Fix [iOS]VerticalOffset Not Reset to Zero After Clearing ItemSource in CollectionView#26818devanathan-vaithiyanathan wants to merge 6 commits intodotnet:mainfrom
devanathan-vaithiyanathan wants to merge 6 commits intodotnet:mainfrom
Conversation
Contributor
|
Hey there @devanathan-vaithiyanathan! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue Details:
When clearing the ItemSource of a CollectionView, the VerticalOffset does not reset to zero on iOS and MacCatalyst. Instead, the last offset value is retained. However, after adding items back to the ItemSource, the VerticalOffset updates as expected when scrolling.
Root Cause:
The UIScrollView.ContentOffset retains its previous value even when the ItemSource is cleared, as there are no visible items in the CollectionView. The VerticalOffset property of the CollectionView depends on the ContentOffset value, which is not reset in such cases.
Description of Change
Reset HorizontalOffset and VerticalOffset to zero when ItemSource is empty and no items are visible.
Issues Fixed
Fixes #26798
Regarding Test case
The test case for this fix is included in this PR
Validated the behaviour in the following platforms
Output Screenshot
BeforeFix.mov
AfterFix.mov