Fixed Label Visibility Issue on macOS and iOS#28081
Merged
PureWeen merged 5 commits intodotnet:inflight/currentfrom Mar 18, 2025
Merged
Fixed Label Visibility Issue on macOS and iOS#28081PureWeen merged 5 commits intodotnet:inflight/currentfrom
PureWeen merged 5 commits intodotnet:inflight/currentfrom
Conversation
Contributor
|
Hey there @Dhivya-SF4094! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
Contributor
There was a problem hiding this comment.
PR Overview
This PR addresses the incomplete label display on macOS and iOS when padding is applied by adjusting the size passed to SizeThatFits.
- Adjust the width and height by subtracting padding values before calculating text size, then add the insets back with AddInsets.
- Add test cases in both TestCases.Shared.Tests and TestCases.HostApp to validate the fix.
Reviewed Changes
| File | Description |
|---|---|
| src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue19007.cs | Added UI test for label with padding. |
| src/Controls/tests/TestCases.HostApp/Issues/Issue19007.cs | Implemented sample page with padded label. |
| src/Core/src/Platform/iOS/MauiLabel.cs | Adjusted SizeThatFits to subtract padding before size calculation. |
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
MartyIX
reviewed
Mar 4, 2025
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues |
Contributor
There was a problem hiding this comment.
Super-nit: After #28040, you can convert this to file-scope namespace by CTRL+. in Visual Studio (I believe it's the same in VS Code).
If it is converted, then new files will use file-scope namespaces more and more as people IMO copy old files to create new code.
Contributor
Author
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
tj-devel709
approved these changes
Mar 14, 2025
4 tasks
PureWeen
pushed a commit
that referenced
this pull request
Mar 26, 2025
* Fixed Label Display on macOS and IOS When Padding is Applied * Optimized the fix * Added test case * Added Snapshot for android and iOS * Added snapshot for winUI and macOS, updated test sample
PureWeen
pushed a commit
that referenced
this pull request
Mar 26, 2025
* Fixed Label Display on macOS and IOS When Padding is Applied * Optimized the fix * Added test case * Added Snapshot for android and iOS * Added snapshot for winUI and macOS, updated test sample
github-actions bot
pushed a commit
that referenced
this pull request
Mar 27, 2025
* Fixed Label Display on macOS and IOS When Padding is Applied * Optimized the fix * Added test case * Added Snapshot for android and iOS * Added snapshot for winUI and macOS, updated test sample
bhavanesh2001
added a commit
to bhavanesh2001/maui
that referenced
this pull request
Apr 11, 2025
This reverts commit 041e041.
bhavanesh2001
added a commit
to bhavanesh2001/maui
that referenced
this pull request
Apr 11, 2025
This reverts commit 041e041.
bhavanesh2001
added a commit
to bhavanesh2001/maui
that referenced
this pull request
Apr 11, 2025
This reverts commit 041e041.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue Details:
In macOS and iOS, a visibility issue arises when a label fails to display fully when padding is applied to it. The label is completely visible when the padding is removed.
Root Cause
When a direct size value is passed to the SizeThatFits() method, it incorrectly assumes that the label has adequate width to accommodate the text, without accounting for the padding. As a result, the height calculation becomes inaccurate.
Description of Change
To resolve this, the padding value should be subtracted from the width before passing it to SizeThatFits(). This adjustment ensures the width is correctly calculated, leading to an accurate height value. Then added the padding value back in the AddInsets method.
Validated the behaviour in the following platforms
Issues Fixed:
Fixes #19007
Fixes #28180
Screenshots
iOS
macOS