-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[CV2][iOS] Fix Header/Footer removed at runtime leaves empty space and EmptyView not resized in CollectionView #31916
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
[CV2][iOS] Fix Header/Footer removed at runtime leaves empty space and EmptyView not resized in CollectionView #31916
Conversation
|
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. |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 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.
Pull Request Overview
This PR fixes an issue where removing a header or footer from a CollectionView at runtime on iOS/macOS left empty space that was still being included in EmptyView frame calculations. The fix adds proper cleanup logic to remove the native views when their content is set to null.
- Added cleanup methods in StructuredItemsViewController2 to remove header/footer views when content is null
- Uncommented and activated existing UpdateHeaderView/UpdateFooterView calls in the handler
- Added comprehensive UI test coverage for both removing and adding header/footer at runtime
Reviewed Changes
Copilot reviewed 4 out of 9 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/Controls/src/Core/Handlers/Items2/iOS/StructuredItemsViewController2.cs |
Added UpdateHeaderView and UpdateFooterView methods to remove native views when content is null |
src/Controls/src/Core/Handlers/Items2/CollectionViewHandler2.iOS.cs |
Uncommented calls to UpdateHeaderView and UpdateFooterView methods |
src/Controls/tests/TestCases.HostApp/Issues/Issue31899.cs |
Added UI test page demonstrating header/footer toggle functionality |
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31899.cs |
Added automated tests for header/footer removal and addition scenarios |
| return new Label | ||
| { | ||
| TextColor = Colors.Black, | ||
| FontSize = 16, | ||
| // This binding works with string items | ||
| BindingContext = "{Binding .}" | ||
| }; |
Copilot
AI
Oct 10, 2025
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.
Setting BindingContext to a string literal instead of using the SetBinding method. This should be SetBinding(Label.TextProperty, new Binding(".")) or use a proper binding syntax.
| return new Label | |
| { | |
| TextColor = Colors.Black, | |
| FontSize = 16, | |
| // This binding works with string items | |
| BindingContext = "{Binding .}" | |
| }; | |
| var label = new Label | |
| { | |
| TextColor = Colors.Black, | |
| FontSize = 16, | |
| }; | |
| label.SetBinding(Label.TextProperty, new Binding(".")); | |
| return label; |
…d EmptyView not resized in CollectionView (#31916) * Update StructuredItemsViewController2.cs * fix updated * Test case added * Update StructuredItemsViewController2.cs * Update Issue31899.cs * Update Issue31899.cs * Test fail changes updated * Order value changed * Added snapshots
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!
Issue Details
When the Header or Footer is set to null at runtime, empty space remains in the layout because their heights are still included while calculating the EmptyView frame.
Description of Change
Added cleanup logic for header and footer views in UpdateHeaderView and UpdateFooterView methods.
When the Header or Footer (or their templates) are set to null, the corresponding native views are now removed from the CollectionView using their assigned tags.
Issues Fixed
Fixes #31899
Tested the behavior in the following platforms.
Output Screenshot
Before.mov
After.mov