Skip to content

[Android] - Fix inconsistent footer scrolling when EmptyView is a string in CollectionView #29381

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

Merged
merged 1 commit into from
May 8, 2025

Conversation

prakashKannanSf3972
Copy link
Contributor

@prakashKannanSf3972 prakashKannanSf3972 commented May 7, 2025

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

  • When the EmptyView is defined as a string, it occupies the entire parent space without considering header and footer dimensions, causing overlaps or forcing the footer into a scrollable area.

Description of Change

  • Enhanced layout logic to account for Header and Footer measurements when the EmptyView is specified as a string. This ensures the EmptyView no longer occupies the entire available space indiscriminately and allows the Footer to remain properly anchored, preserving the correct layout.
  • Enhanced UpdateHeaderFooterHeight to handle string-based content by creating a Label for measurement, ensuring accurate height calculations for header and footer items.

Issues Fixed

Fixes #28765

Tested the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Output

Before After
BeforeFix_Scrolling.mov
AftetFix_Fit.mov

@dotnet-policy-service dotnet-policy-service bot added community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration labels May 7, 2025
@prakashKannanSf3972 prakashKannanSf3972 changed the title [Android] - Fix footer scrolling issue when EmptyView is a string in CollectionView [Android] - Fix inconsistent footer scrolling when EmptyView is a string in CollectionView May 8, 2025
@jsuarezruiz jsuarezruiz added platform/android area-controls-collectionview CollectionView, CarouselView, IndicatorView labels May 8, 2025
@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@prakashKannanSf3972 prakashKannanSf3972 marked this pull request as ready for review May 8, 2025 13:04
@Copilot Copilot AI review requested due to automatic review settings May 8, 2025 13:04
@prakashKannanSf3972 prakashKannanSf3972 requested a review from a team as a code owner May 8, 2025 13:04
Copy link
Contributor

@Copilot Copilot AI left a 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 the footer scrolling issue on Android when an EmptyView is provided as a string by adjusting the layout logic to account for header and footer measurements.

  • Updated test cases to verify both string and view-based headers/footers.
  • Modified SimpleViewHolder.FromText to support dynamic width and height measurement.
  • Enhanced the EmptyViewAdapter to measure string-based EmptyViews correctly by using a Label for accurate size calculations.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue28765.cs Added test cases for different Header/Footer setups.
src/Controls/tests/TestCases.HostApp/Issues/Issue28765.cs Updated the host app to include scenarios for string-based headers/footers.
src/Controls/src/Core/Handlers/Items/Android/SimpleViewHolder.cs Modified the FromText method signature to include width/height delegates and improved EmptyView layout handling.
src/Controls/src/Core/Handlers/Items/Android/Adapters/EmptyViewAdapter.cs Adjusted view holder creation and header/footer measurement to support string-based EmptyViews.

@@ -27,19 +27,19 @@ public void Recycle(ItemsView itemsView)
itemsView.RemoveLogicalChild(View);
}

Copy link
Preview

Copilot AI May 8, 2025

Choose a reason for hiding this comment

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

[nitpick] The new parameters (width, height, and container) increase the method signature complexity. Consider adding inline documentation to clearly explain the purpose and expected usage of these parameters.

Suggested change
/// <summary>
/// Creates a SimpleViewHolder containing a text-based view.
/// </summary>
/// <param name="text">The text to display in the view.</param>
/// <param name="context">The Android context used to create the view.</param>
/// <param name="width">An optional function to calculate the width of the view.</param>
/// <param name="height">An optional function to calculate the height of the view.</param>
/// <param name="container">An optional ItemsView container for the view.</param>
/// <param name="fill">If true, the view will fill the available space; otherwise, it will not.</param>

Copilot uses AI. Check for mistakes.

@@ -319,6 +319,14 @@ void UpdateHeaderFooterHeight(object item, bool isHeader)
size = content.Measure(double.PositiveInfinity, double.PositiveInfinity);
}

if (item is string text)
{
Label label = new Label { Text = text };
Copy link
Preview

Copilot AI May 8, 2025

Choose a reason for hiding this comment

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

[nitpick] A new branch has been added to handle string-based header/footer measurement using a Label. Adding an inline comment to explain why TemplateHelpers.GetHandler is called on the Label will help future maintainers understand this logic.

Suggested change
Label label = new Label { Text = text };
Label label = new Label { Text = text };
// Ensure the Label is initialized with a handler so it can be measured correctly.

Copilot uses AI. Check for mistakes.

@@ -319,6 +319,14 @@ void UpdateHeaderFooterHeight(object item, bool isHeader)
size = content.Measure(double.PositiveInfinity, double.PositiveInfinity);
}

if (item is string text)
{
Label label = new Label { Text = text };
Copy link
Member

Choose a reason for hiding this comment

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

Doesn t it need a parent to get layout correctly ?

rmarinho
rmarinho previously approved these changes May 8, 2025
textView.LayoutParameters = layoutParams;
// When displaying an EmptyView with Header and Footer, we need to account for the Header and Footer sizes in layout calculations.
// This prevents the EmptyView from occupying the full remaining space.
Label label = new Label() { Text = text, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center };
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if this should center the text horizontally

@dotnet dotnet deleted a comment from azure-pipelines bot May 8, 2025
@PureWeen PureWeen changed the base branch from main to inflight/current May 8, 2025 16:19
@PureWeen PureWeen dismissed rmarinho’s stale review May 8, 2025 16:19

The base branch was changed.

@PureWeen PureWeen merged commit 59251eb into dotnet:inflight/current May 8, 2025
102 of 114 checks passed
PureWeen pushed a commit that referenced this pull request May 9, 2025
PureWeen pushed a commit that referenced this pull request May 13, 2025
github-actions bot pushed a commit that referenced this pull request May 13, 2025
PureWeen pushed a commit that referenced this pull request May 14, 2025
PureWeen pushed a commit that referenced this pull request May 14, 2025
github-actions bot pushed a commit that referenced this pull request May 15, 2025
PureWeen added a commit that referenced this pull request May 21, 2025
For more information about inflight process check
https://github.com/dotnet/maui/wiki/Inflight-Branch-Process

# .NET MAUI Release Notes

## New Release: May 21, 2025

We're excited to announce a new release of .NET MAUI with several bug
fixes and improvements across various platforms.

### Bug Fixes

#### iOS
- **Map Control**: Fixed crash when navigating to a page containing a
map more than once (#29369)
- **CarouselView**: Fixed bounce-back behavior when Loop=false, ensuring
proper scrolling experience (#29318)
- **UIView**: Fixed NullReferenceException for UIView not being in
UIWindow (#29460)

#### Windows
- **CarouselView**: Fixed HorizontalScrollBarVisibility="Never" not
working properly (#29343)
- **UI Controls**: Fixed the color not being applied to the
Expand/Collapse Chevron icon (#29140)

#### Windows & macOS
- **Modal Navigation**: Fixed issue where Disappearing event was not
triggered when closing a window with a modal page (#29129)

#### Android
- **Modal Pages**: Improved inheritance of StatusBar and NavigationBar
background colors (#28568)
- **Footer Scrolling**: Fixed footer scrolling issues in list controls
(#29381)
- **Modal Pages**: Improved inheritance of StatusBar and NavigationBar
background colors on modal pages (#28568)

#### Cross-Platform
- **CarouselView**: Fixed ItemsLayout runtime updates to ensure proper
layout behavior (#29447)
- **CollectionView**: Fixed various issues in CollectionView
implementation (#29423)

### Testing Improvements
- Added feature matrix UITest cases for CollectionView dynamic changes
(#29424)

### Code Quality
- Fixed code formatting issues across the codebase
- Minor typo corrections (#29379)

### Contributors

This release was made possible by the hard work of our dedicated team
and community contributors. We'd like to extend our gratitude to
everyone who has contributed to this release.

### Installation

This update is available through NuGet and the .NET SDK. Update your
projects to get access to these fixes.

### Known Issues

Please refer to our issue tracker for any known issues and their
workarounds.

---

For more information about .NET MAUI, visit [the official
documentation](https://docs.microsoft.com/dotnet/maui/).
PureWeen pushed a commit that referenced this pull request May 21, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Jun 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Android] Inconsistent footer scrolling in CollectionView when EmptyView as string
4 participants