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

[Android] Fixed border inside frame not rendering #20974

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?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.Issue18526">

<Frame Padding="30" Margin="30"
HorizontalOptions="Center"
VerticalOptions="Start" >
<Border Stroke="#C49B33"
StrokeThickness="4"
StrokeShape="RoundRectangle 40,0,0,40"
Background="#2B0B98"
Padding="16,8"
HorizontalOptions="Center" Grid.Row="0">
<Label Text=".NET MAUI"
AutomationId="label"
TextColor="White"
FontSize="18"
FontAttributes="Bold" />
</Border>
</Frame>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Xaml;

namespace Maui.Controls.Sample.Issues;

[XamlCompilation(XamlCompilationOptions.Compile)]
[Issue(IssueTracker.Github, 18526, "Border not rendering inside a frame", PlatformAffected.All)]

public partial class Issue18526 : ContentPage
{
public Issue18526()
{
InitializeComponent();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,18 @@ void UpdateContent()
if (content == null || _mauiContext == null)
return;

if (content is Border border)
{
foreach (var child in border.LogicalChildrenInternal)
{
if (child is IShape)
{
((VisualElement)child).IsVisible = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you share more details about this change?

Copy link
Contributor Author

@kubaflo kubaflo Mar 4, 2024

Choose a reason for hiding this comment

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

@jsuarezruiz When we set the property IsVisible to false then the parent layout doesn't consider this shape when calculating the required size for its content.

https://github.com/kubaflo/maui/blob/9d50c370103718c654d67d51fc13827719f125fa/src/Controls/src/Core/Layout.cs#L663

Copy link
Member

Choose a reason for hiding this comment

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

Can we just set DisableLayout to true?

if (Width <= 0 || Height <= 0 || !LogicalChildrenInternal.Any() || !IsVisible || !IsPlatformStateConsistent || DisableLayout)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@PureWeen I tried but it doesn't work:

                       if (content is Border border)
			{
				var shape = border.LogicalChildrenInternal.FirstOrDefault(child => child is IShape);
				if (shape is VisualElement visualElement)
				{
					visualElement.DisableLayout = true; // doesn't work
					visualElement.IsVisible = false; // works
				}
			}

break;
}
}
}

var platformView = content.ToPlatform(_mauiContext);
AddView(platformView);
}
Expand Down
22 changes: 22 additions & 0 deletions src/Controls/tests/UITests/Tests/Issues/Issue18526.cs
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.AppiumTests.Issues;

public class Issue18526 : _IssuesUITest
{
public override string Issue => "Border not rendering inside a frame";

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

[Test]
public void BorderShouldRender()
{
var label = App.WaitForElement("label");

Assert.True(label.GetText() == ".NET MAUI");
}
}
Loading