Skip to content

[iOS] CollectionView: Fix pull-to-refresh when empty - #38296

Merged
kubaflo merged 1 commit into
mainfrom
kubaflo-forward-port-ios-refresh
Sep 7, 2026
Merged

kubaflo merged 1 commit into
mainfrom
kubaflo-forward-port-ios-refresh

Conversation

@kubaflo

@kubaflo kubaflo commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

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 UICollectionView to avoid mirrored RTL rendering. As a full-size sibling, the empty view intercepted pull gestures before the collection view and its RefreshView integration could receive them.

Description of Change

  • Keep the empty view inside the native UICollectionView so pull gestures reach the scroll view.
  • Preserve LTR/RTL rendering by applying the content flow direction separately and counter-transforming the empty-view host when needed.
  • Reset the transform before assigning a changed frame, then restore alignment after layout because UIKit frame values are undefined under a non-identity transform.
  • Add the Issue37361 HostApp scenario and iOS UI regression test for both an initially empty collection and an add/clear transition.

This is a focused forward-port of #37404 from inflight/current to main (source merge commit 53ba0dbbb67f13e864fb2e03cbb2d32335f2b2fb).

Issues Fixed

Fixes #37361

Validation

  • dotnet build Microsoft.Maui.BuildTasks.slnf
  • pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform ios -TestFilter "FullyQualifiedName~Issue37361"

Forward-port the focused fix and regression coverage from #37404 to main.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 7, 2026 17:48
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool September 7, 2026 17:48 — with GitHub Actions Inactive
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 38296

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 38296"

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@kubaflo
kubaflo temporarily deployed to copilot-pat-pool September 7, 2026 17:48 — with GitHub Actions Inactive
@kubaflo kubaflo changed the title [iOS] Fix pull-to-refresh for empty CollectionView [iOS] CollectionView: Fix pull-to-refresh when empty Sep 7, 2026
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool September 7, 2026 17:49 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool September 7, 2026 17:51 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool September 7, 2026 17:52 — with GitHub Actions Inactive
@github-actions github-actions Bot added area-controls-collectionview CollectionView, CarouselView, IndicatorView platform/ios labels Sep 7, 2026
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool September 7, 2026 17:53 — with GitHub Actions Inactive
@kubaflo

kubaflo commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

@dalexsoto stamp

@kubaflo

kubaflo commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

This is a back port from sr10.1

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 UICollectionView so the scroll view receives pan gestures needed for RefreshView.
  • 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

Comment on lines +680 to +684
{
// 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.
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 8, 2026

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — bcb12a13 Deployed Sep 7, 2026 by kubaflo via conclusion #1779
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-collectionview CollectionView, CarouselView, IndicatorView platform/ios

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iOS] RefreshView pull-to-refresh does nothing when the CollectionView is empty (regression in 10.0.90, from #32674)

3 participants