Skip to content

Conversation

@Dhivya-SF4094
Copy link
Contributor

@Dhivya-SF4094 Dhivya-SF4094 commented Feb 27, 2025

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

  • Android
  • Windows
  • iOS
  • Mac

Issues Fixed:

Fixes #19007
Fixes #28180

Screenshots

iOS

Before After
   

macOS

Before  After 
   

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Feb 27, 2025
@dotnet-policy-service
Copy link
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.

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Feb 27, 2025
@jsuarezruiz jsuarezruiz changed the title Fix 19007 Fix Visibility Issues Feb 27, 2025
@Dhivya-SF4094 Dhivya-SF4094 changed the title Fix Visibility Issues Fix Label Visibility Issue on macOS and iOS Feb 28, 2025
@Dhivya-SF4094 Dhivya-SF4094 changed the title Fix Label Visibility Issue on macOS and iOS Fixed Label Visibility Issue on macOS and iOS Feb 28, 2025
@Dhivya-SF4094 Dhivya-SF4094 marked this pull request as ready for review February 28, 2025 11:50
Copilot AI review requested due to automatic review settings February 28, 2025 11:50
@Dhivya-SF4094 Dhivya-SF4094 requested a review from a team as a code owner February 28, 2025 11:50
Copy link
Contributor

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.

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.

@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MartyIX Converted the shared file to file-scope namespace as per #28040

@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen changed the base branch from main to inflight/current March 18, 2025 18:21
@PureWeen PureWeen merged commit 041e041 into dotnet:inflight/current Mar 18, 2025
122 of 129 checks passed
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
bhavanesh2001 added a commit to bhavanesh2001/maui that referenced this pull request Apr 11, 2025
bhavanesh2001 added a commit to bhavanesh2001/maui that referenced this pull request Apr 11, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Apr 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/ios platform/macos macOS / Mac Catalyst

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Labels with Padding are truncated on IOS Visibility Issues: Incomplete Label Display on macOS and IOS When Padding is Applied

5 participants