Repository navigation
[iOS] CollectionView: Fix pull-to-refresh when empty - #38296
Conversation
Forward-port the focused fix and regression coverage from #37404 to main. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 38296Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 38296" |
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
|
@dalexsoto stamp |
|
This is a back port from sr10.1 |
There was a problem hiding this comment.
🟡 Changes recommended
The empty view frame calculation is still using superview coordinates after rehosting inside CollectionView, and the new UITest guard currently includes Android unexpectedly.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR fixes an iOS (Items2) CollectionView regression where the EmptyView overlay prevented pull-to-refresh gestures when the items source is empty, by moving the empty view back inside the native UICollectionView and compensating for RTL rendering via transforms. It also adds a HostApp repro page and an automated UI regression test for the empty-list refresh scenario.
Changes:
- Rehost EmptyView as a subview of
UICollectionViewso the scroll view receives pan gestures needed forRefreshView. - Add RTL counter-transform + adjust transform/frame sequencing during layout to avoid undefined UIKit frame behavior under transforms.
- Add Issue37361 HostApp page and a UITest validating refresh on initially-empty and after add/clear transitions.
File summaries
| File | Description |
|---|---|
| src/Controls/src/Core/Handlers/Items2/iOS/ItemsViewController2.cs | Rehosts EmptyView inside the collection view and applies RTL/transform/layout adjustments to preserve correct rendering while restoring pull-to-refresh. |
| src/Controls/tests/TestCases.HostApp/Issues/Issue37361.cs | Adds a minimal repro page with a RefreshView + empty CollectionView and add/clear controls. |
| src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue37361.cs | Adds a UI regression test that triggers pull-to-refresh in the empty state and after transitioning back to empty. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 2
- Review effort level: Lite
| { | ||
| // UIKit's Frame is undefined under a non-identity transform. | ||
| _emptyUIView.Transform = CGAffineTransform.MakeIdentity(); | ||
| _emptyUIView.Frame = frame; | ||
| } |
| @@ -0,0 +1,33 @@ | |||
| #if TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_WINDOWS // Windows requires touch interaction; App.ScrollUp does not work on MacCatalyst. | |||
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Root Cause
PR #32674 moved the Items2 empty view above the native
UICollectionViewto avoid mirrored RTL rendering. As a full-size sibling, the empty view intercepted pull gestures before the collection view and itsRefreshViewintegration could receive them.Description of Change
UICollectionViewso pull gestures reach the scroll view.This is a focused forward-port of #37404 from
inflight/currenttomain(source merge commit53ba0dbbb67f13e864fb2e03cbb2d32335f2b2fb).Issues Fixed
Fixes #37361
Validation
dotnet build Microsoft.Maui.BuildTasks.slnfpwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform ios -TestFilter "FullyQualifiedName~Issue37361"