Skip to content
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

Fixed the Label height within VerticalStackLayout is truncated when width is set #25748

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue15559.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue15559"
Title="Issue15559">

<VerticalStackLayout Spacing="20" Margin="20">

<VerticalStackLayout WidthRequest="200" BackgroundColor="Yellow">
<Label Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore."/>
</VerticalStackLayout>

<VerticalStackLayout BackgroundColor="Yellow">
<Label AutomationId="Label" WidthRequest="200" Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore."/>
</VerticalStackLayout>
</VerticalStackLayout>
</ContentPage>
11 changes: 11 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue15559.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 15559, "[iOS] Vertical layout content of label is truncated when a width request is set in the layout", PlatformAffected.iOS | PlatformAffected.macOS)]

public partial class Issue15559 : ContentPage
{
public Issue15559()
{
InitializeComponent();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue15559 : _IssuesUITest
{
public override string Issue => "[iOS] Vertical layout content of label is truncated when a width request is set in the layout";

public Issue15559(TestDevice device) : base(device)
{ }

[Test]
[Category(UITestCategories.Layout)]
public void LabelDisplayWithoutCroppingInsideVerticalLayout()
{
App.WaitForElement("Label");
VerifyScreenshot();
Copy link
Contributor

Choose a reason for hiding this comment

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

The Windows snapshot is pending, already available in the latest build.
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @jsuarezruiz ,
Included the snapshot for the Windows platform. Could you please check and let me know?

}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions src/Core/src/Handlers/ViewHandlerExtensions.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ internal static Size GetDesiredSizeFromHandler(this IViewHandler viewHandler, do

sizeThatFits = imageView.SizeThatFitsImage(new CGSize((float)widthConstraint, (float)heightConstraint));
}
else if (platformView is LayoutView || platformView is MauiLabel)
{
widthConstraint = IsExplicitSet(virtualView.Width) ? virtualView.Width : widthConstraint;
heightConstraint = IsExplicitSet(virtualView.Height) ? virtualView.Height : heightConstraint;

sizeThatFits = platformView.SizeThatFits(new CGSize((float)widthConstraint, (float)heightConstraint));
}
else if (platformView is WrapperView wrapper)
{
sizeThatFits = wrapper.SizeThatFitsWrapper(new CGSize((float)widthConstraint, (float)heightConstraint), virtualView.Width, virtualView.Height, virtualView);
Expand Down
Loading