-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[iOS] CollectionView item sizing wrong after refresh #21736
[iOS] CollectionView item sizing wrong after refresh #21736
Conversation
@dotnet-policy-service agree |
What are the next steps for this PR? |
/rebase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you try this with the main rebased ? It would use the new handler for collectionview2 . Also can we add a UITest? you can look at other examples with VerifyScreenshot.
4e36d3f
to
0566fa9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't seem to fix #24961 and I think we ca drop the ItemSize
@rmarinho I was able to reproduce this issue with my app on 8.0.92 - I had different size views in the CollectionView and tried to refresh the collection several times and scrolling up and down. At some point I was able to reproduce the issue. I believe there are some steps missing on the way to reproduce this one for sure. Then I updated to .NET 9 and MAUI 9.0.12 and I was able to reproduce that again. So new handler does not seem to have a fix. |
@softeip are you using CollectionViewHandler2 ? |
@rmarinho No, my bad. Added CollectionViewHandler2 manually and retested. Now I see that the issue is not reproducable no matter what I do and have many times I refresh the collection. I would say that the new handler fixes the sizing issue at least for my app. |
Nice, yeah that matches my testing, but this will fix using the CollectionView 1 and is still the default one. |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…temSize when size cache gets cleared Clear
352c588
to
c4f7096
Compare
OK after playing with it seems the issue is setting |
@@ -113,6 +113,8 @@ internal virtual bool UpdateConstraints(CGSize size) | |||
|
|||
ClearCellSizeCache(); | |||
|
|||
EstimatedItemSize = CGSize.Empty; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we use empty specifically to know we need to estimate the size?
Just wanting to make sure we shouldn't be using UICollectionViewFlowLayout.AutomaticSize
which has a specific meaning (and is not equivalent to Empty). I am guessing we want Empty here since we do the manually measurement on CV1 still, but wanted to be sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like no, we should not use automatic size.
There is a call to ConstrainTo()
method which is implemented in the ItemsViewLayout
subclasses. Their implementation calls DetermineCellSize()
which have some checks for EstimatedItemSize == CGSize.Empty
. There is a comment saying about <iOS 10 fix (237 line in this file). Using UICollectionViewFlowLayout.AutomaticSize
can lead to crashes and would require further fixes.
Description of Change
Added reset of EstimatedItemSize and ItemSize when the size cache gets cleared
Issues Fixed
Fixes #20443