Skip to content

Revert - Fixed the Label not sized correctly on Android #30023

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 3 commits into from
Jun 19, 2025

Conversation

Ahamed-Ali
Copy link
Contributor

@Ahamed-Ali Ahamed-Ali commented Jun 17, 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!

Reverts: #27614 & #29194

Description for revert:

The original issue #27614, reported by Javier, still reproduces if we revert the OnMeasure override in the TextView. This issue also exists in Xamarin and appears to be a native issue. The OnMeasure code was introduced in MAUI to resolve it, but it introduced regressions in other cases.

So, it's better to revert the OnMeasure changes and, as you mentioned, included the tests for the case described in Issue #29542 in this PR.

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jun 17, 2025
Copy link
Contributor

Hey there @@Ahamed-Ali! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Jun 17, 2025
@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@Ahamed-Ali Ahamed-Ali marked this pull request as ready for review June 17, 2025 09:19
@Copilot Copilot AI review requested due to automatic review settings June 17, 2025 09:19
@Ahamed-Ali Ahamed-Ali requested a review from a team as a code owner June 17, 2025 09:19
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 reverts the custom OnMeasure override for MauiTextView on Android, restoring the native measurement behavior. The changes remove the OnMeasure override from the public API and platform implementation, remove deprecated tests for Issue27614, and add tests for Issue29542 to validate the updated behavior.

  • Revert the OnMeasure override in MauiTextView (Android) by removing its implementation and public API entry.
  • Remove Issue27614 test cases and introduce Issue29542 tests to check label sizing behavior.

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Core/src/PublicAPI/net-android/PublicAPI.Shipped.txt Removed the OnMeasure override signature for MauiTextView
src/Core/src/Platform/Android/MauiTextView.cs Removed the custom OnMeasure override and its helper method
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue29542.cs Added tests for verifying label sizing with the current behavior
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue27614.cs Removed tests for the previous implementation
src/Controls/tests/TestCases.HostApp/Issues/Issue29542.cs Added host app test for Issue29542
src/Controls/tests/TestCases.HostApp/Issues/Issue27614.cs Removed host app test for Issue27614
Comments suppressed due to low confidence (3)

src/Core/src/PublicAPI/net-android/PublicAPI.Shipped.txt:2387

  • The removal of the OnMeasure override from the shipped public API represents a breaking change; please confirm that all relevant consumers have been informed of this change.
override Microsoft.Maui.Platform.MauiTextView.OnMeasure(int widthMeasureSpec, int heightMeasureSpec) -> void

src/Core/src/Platform/Android/MauiTextView.cs:18

  • Removing the custom OnMeasure override reverts to native behavior; ensure that comprehensive testing is in place to verify that label sizing behaves as expected across all scenarios.
protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec) { ... }

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue29542.cs:1

  • Please verify that the new tests in Issue29542 provide comprehensive coverage for label sizing behavior previously addressed by the removed Issue27614 tests.
#if TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_WINDOWS ...

@PureWeen
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@@ -2385,7 +2385,6 @@ override Microsoft.Maui.Platform.MauiSwipeView.OnAttachedToWindow() -> void
override Microsoft.Maui.Platform.MauiSwipeView.OnInterceptTouchEvent(Android.Views.MotionEvent? e) -> bool
override Microsoft.Maui.Platform.MauiSwipeView.OnLayout(bool changed, int left, int top, int right, int bottom) -> void
override Microsoft.Maui.Platform.MauiSwipeView.OnTouchEvent(Android.Views.MotionEvent? e) -> bool
override Microsoft.Maui.Platform.MauiTextView.OnMeasure(int widthMeasureSpec, int heightMeasureSpec) -> void
Copy link
Member

Choose a reason for hiding this comment

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

Can you make this change inside unshipped?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I have updated the change inside unshipped @PureWeen

@PureWeen
Copy link
Member

/azp run

@PureWeen PureWeen modified the milestone: .NET 9 SR9 Jun 18, 2025
@PureWeen PureWeen added p/0 Work that we can't release without labels Jun 18, 2025
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@github-project-automation github-project-automation bot moved this from Todo to Approved in MAUI SDK Ongoing Jun 18, 2025
@PureWeen PureWeen changed the base branch from main to inflight/current June 19, 2025 13:40
@PureWeen
Copy link
Member

/backport to release/9.0.1xx-sr8

Copy link
Contributor

Started backporting to release/9.0.1xx-sr8: https://github.com/dotnet/maui/actions/runs/15759323465

Copy link
Contributor

@PureWeen backporting to "release/9.0.1xx-sr8" failed, the patch most likely resulted in conflicts:

$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Reverting the OnMeasure changes and 27614 test cases
.git/rebase-apply/patch:6484: trailing whitespace.
			Text = @"DescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescription DescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescription 
warning: 1 line adds whitespace errors.
Using index info to reconstruct a base tree...
M	src/Core/src/PublicAPI/net-android/PublicAPI.Shipped.txt
Falling back to patching base and 3-way merge...
Auto-merging src/Core/src/PublicAPI/net-android/PublicAPI.Shipped.txt
Removing src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/LabelShouldSizeCorrectlyOnHorizontalStartLayoutOptions.png
Removing src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/LabelShouldSizeCorrectlyOnHorizontalEndLayoutOptions.png
Removing src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/LabelShouldSizeCorrectlyOnHorizontalCenterLayoutOptions.png
Removing src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/LabelShouldSizeCorrectlyOnHorizontalStartLayoutOptions.png
Removing src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/LabelShouldSizeCorrectlyOnHorizontalEndLayoutOptions.png
Removing src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/LabelShouldSizeCorrectlyOnHorizontalCenterLayoutOptions.png
Removing src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue27614.cs
Removing src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/LabelShouldSizeCorrectlyOnHorizontalStartLayoutOptions.png
Removing src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/LabelShouldSizeCorrectlyOnHorizontalEndLayoutOptions.png
Removing src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/LabelShouldSizeCorrectlyOnHorizontalCenterLayoutOptions.png
Removing src/Controls/tests/TestCases.HostApp/Issues/Issue27614.cs
Removing src/Controls/tests/TestCases.Android.Tests/snapshots/android/LabelShouldSizeCorrectlyOnHorizontalStartLayoutOptions.png
Removing src/Controls/tests/TestCases.Android.Tests/snapshots/android/LabelShouldSizeCorrectlyOnHorizontalEndLayoutOptions.png
Removing src/Controls/tests/TestCases.Android.Tests/snapshots/android/LabelShouldSizeCorrectlyOnHorizontalCenterLayoutOptions.png
Applying: Resaved the Android images
Applying: Change in unshipped file
Using index info to reconstruct a base tree...
M	src/Core/src/PublicAPI/net-android/PublicAPI.Shipped.txt
M	src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt
Falling back to patching base and 3-way merge...
Auto-merging src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt
CONFLICT (content): Merge conflict in src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt
Auto-merging src/Core/src/PublicAPI/net-android/PublicAPI.Shipped.txt
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0003 Change in unshipped file
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

@PureWeen
Copy link
Member

/backport to release/9.0.1xx-sr8

Copy link
Contributor

Started backporting to release/9.0.1xx-sr8: https://github.com/dotnet/maui/actions/runs/15763584311

Copy link
Contributor

@PureWeen backporting to "release/9.0.1xx-sr8" failed, the patch most likely resulted in conflicts:

$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Reverting the OnMeasure changes and 27614 test cases
.git/rebase-apply/patch:6484: trailing whitespace.
			Text = @"DescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescription DescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescriptionDescription 
warning: 1 line adds whitespace errors.
Using index info to reconstruct a base tree...
M	src/Core/src/PublicAPI/net-android/PublicAPI.Shipped.txt
Falling back to patching base and 3-way merge...
Auto-merging src/Core/src/PublicAPI/net-android/PublicAPI.Shipped.txt
Removing src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/LabelShouldSizeCorrectlyOnHorizontalStartLayoutOptions.png
Removing src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/LabelShouldSizeCorrectlyOnHorizontalEndLayoutOptions.png
Removing src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/LabelShouldSizeCorrectlyOnHorizontalCenterLayoutOptions.png
Removing src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/LabelShouldSizeCorrectlyOnHorizontalStartLayoutOptions.png
Removing src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/LabelShouldSizeCorrectlyOnHorizontalEndLayoutOptions.png
Removing src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/LabelShouldSizeCorrectlyOnHorizontalCenterLayoutOptions.png
Removing src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue27614.cs
Removing src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/LabelShouldSizeCorrectlyOnHorizontalStartLayoutOptions.png
Removing src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/LabelShouldSizeCorrectlyOnHorizontalEndLayoutOptions.png
Removing src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/LabelShouldSizeCorrectlyOnHorizontalCenterLayoutOptions.png
Removing src/Controls/tests/TestCases.HostApp/Issues/Issue27614.cs
Removing src/Controls/tests/TestCases.Android.Tests/snapshots/android/LabelShouldSizeCorrectlyOnHorizontalStartLayoutOptions.png
Removing src/Controls/tests/TestCases.Android.Tests/snapshots/android/LabelShouldSizeCorrectlyOnHorizontalEndLayoutOptions.png
Removing src/Controls/tests/TestCases.Android.Tests/snapshots/android/LabelShouldSizeCorrectlyOnHorizontalCenterLayoutOptions.png
Applying: Resaved the Android images
Applying: Change in unshipped file
Using index info to reconstruct a base tree...
M	src/Core/src/PublicAPI/net-android/PublicAPI.Shipped.txt
M	src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt
Falling back to patching base and 3-way merge...
Auto-merging src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt
CONFLICT (content): Merge conflict in src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt
Auto-merging src/Core/src/PublicAPI/net-android/PublicAPI.Shipped.txt
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0003 Change in unshipped file
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

@PureWeen PureWeen merged commit 96ede1c into dotnet:inflight/current Jun 19, 2025
1 check passed
@github-project-automation github-project-automation bot moved this from Approved to Done in MAUI SDK Ongoing Jun 19, 2025
PureWeen pushed a commit that referenced this pull request Jun 19, 2025
* Reverting the OnMeasure changes and 27614 test cases

* Resaved the Android images

* Change in unshipped file
# Conflicts:
#	src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt
PureWeen added a commit that referenced this pull request Jun 20, 2025
)

* Reverting the OnMeasure changes and 27614 test cases

* Resaved the Android images

* Change in unshipped file
# Conflicts:
#	src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt

Co-authored-by: Ahamed-Ali <[email protected]>
PureWeen pushed a commit that referenced this pull request Jun 21, 2025
* Reverting the OnMeasure changes and 27614 test cases

* Resaved the Android images

* Change in unshipped file
PureWeen pushed a commit that referenced this pull request Jun 25, 2025
* Reverting the OnMeasure changes and 27614 test cases

* Resaved the Android images

* Change in unshipped file
PureWeen pushed a commit that referenced this pull request Jun 25, 2025
* Reverting the OnMeasure changes and 27614 test cases

* Resaved the Android images

* Change in unshipped file
github-actions bot pushed a commit that referenced this pull request Jun 26, 2025
* Reverting the OnMeasure changes and 27614 test cases

* Resaved the Android images

* Change in unshipped file
github-actions bot pushed a commit that referenced this pull request Jun 26, 2025
* Reverting the OnMeasure changes and 27614 test cases

* Resaved the Android images

* Change in unshipped file
PureWeen pushed a commit that referenced this pull request Jun 27, 2025
* Reverting the OnMeasure changes and 27614 test cases

* Resaved the Android images

* Change in unshipped file
github-actions bot pushed a commit that referenced this pull request Jun 27, 2025
* Reverting the OnMeasure changes and 27614 test cases

* Resaved the Android images

* Change in unshipped file
PureWeen pushed a commit that referenced this pull request Jun 27, 2025
* Reverting the OnMeasure changes and 27614 test cases

* Resaved the Android images

* Change in unshipped file
PureWeen added a commit that referenced this pull request Jun 28, 2025
For more information about inflight process check
https://github.com/dotnet/maui/wiki/Inflight-Branch-Process

# .NET MAUI Release Notes - Inflight/Candidate Branch

## What's Changed

### MAUI Product Fixes
* [iOS] CarouselView with CarouselViewHandler2 make app crash when
Loop="False" and user scroll to the last position - fixes #26863 by
@kubaflo in #26868
* Fixes Setting BackgroundColor to null does not actually changes
BackgroundColor - fixes #22914 and #19576 by @jgonzalez-gft in
#22917
* Fixed the picker title's color - fixes #16737 by @kubaflo in
#23075
* [android] Fallback to default icons in SearchHandler by @aheubusch in
#25067
* ScrollView's Background on iOS - fixes #24016 by @kubaflo in
#25541
* [iOS] Enabled MultiTouch Support for Handling Multi-Touch Points in
GraphicsView - fixes #29461 by @prakashKannanSf3972 in
#29895
* Optimize converters for GridLength, ColumnDefinition, and
RowDefinition - performance improvement by @emiller in
#20048
* Add defensive IsAlive check to Android ViewExtensions.OnUnloaded -
fixes #28051 by @jfversluis in #29934
* [Windows] Fixed runtime update issue for SearchBar PlaceholderColor
and BackgroundColor - fixes #29962 by @Tamilarasan-Paranthaman in
#29965
* Weak subscription to CanExecuteChange events - fixes #16124 by
@sneumaier in #29837
* [iOS, Mac] Fix for downsized image retaining original dimensions in
GraphicsView - fixes #30006 by @SyedAbdulAzeemSF4852 in
#30007
* [Android] Prevent Picker from Gaining Focus on Touch - fixes #19739,
#8546, #13503, #24862, #28121, #21704, #15394 by @bhavanesh2001 in
#29068
* Fix CV1 GridItemsLayout centering single item AND Fix Empty view not
resizing when bounds change - fixes #29595, #29634 by @albyrock87 in
#29639

### Testing
* [Testing] Feature Matrix UITest Cases for Button by @TamilarasanSF4853
in #29803
* [Testing] Feature matrix UITest Cases for BoxView Control by
@HarishKumarSF4517 in #29808
* [Testing] Enable HandlerDoesNotLeak for Button and ProgressBar by
@bhavanesh2001 in #29896
* [Testing] Add Validation Test For Issue28051 On Android by
@prakashKannanSf3972 in #30026
* [Testing] Fixed Test case failure in PR 30115 - [2025/06/23] Candidate
by @HarishKumarSF4517 in #30136

### Dependency Updates
* Bump to 1.7.250606001 of WindowsAppSDK by @sneumaier in
#29915

### Housekeeping
* [housekeeping] Update namespaces in HostApp and Shared tests projects
by @bhavanesh2001 in #29904
* Update SetterSpecificity.cs Remove Extra Line From Bad Merge by
@sneumaier in #29987
* Revert - Fixed the Label not sized correctly on Android by @Ahamed-Ali
in #30023
* Revert "Fixes Setting BackgroundColor to null does not actually
changes BackgroundColor #22914 (#22917)" by @mattleibow in
#30031
* [create-pull-request] automated change by @github-actions[bot] in
#30019
* [create-pull-request] automated change by @github-actions[bot] in
#30043
* [create-pull-request] automated change by @github-actions[bot] in
#30078
* Update Controls.TestCases.HostApp.csproj by @HarishKumarSF4517 in
#30124

## New Contributors
* @albyrock87 made their first contribution in
#29639
* @SyedAbdulAzeemSF4852 made their first contribution in
#30007
* @emiller made their first contribution in
#20048
* @jgonzalez-gft made their first contribution in
#22917
* @aheubusch made their first contribution in
#25067

**Full Changelog**:
https://github.com/dotnet/maui/compare/main..inflight/candidate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-label Label, Span community ✨ Community Contribution p/0 Work that we can't release without partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants