Skip to content

Commit

Permalink
Fixed-Shell-TemplateView-Initial-Margin
Browse files Browse the repository at this point in the history
  • Loading branch information
prakashKannanSf3972 authored and rmarinho committed Jan 11, 2025
1 parent 5b80786 commit 290749b
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ void ShellElementPropertyChanged(object sender, PropertyChangedEventArgs e)

protected override global::Windows.Foundation.Size ArrangeOverride(global::Windows.Foundation.Size finalSize)
{
if (this.ActualWidth > 0 && _content is IView view)
// Replaced ActualWidth with finalSize.Width since ActualWidth updates only after ArrangeOverride completes,
// ensuring accurate layout during the initial arrangement phase.
if (finalSize.Width > 0 && _content is IView view)
{
view.Arrange(new Rect(0, 0, finalSize.Width, finalSize.Height));
return finalSize;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue18423.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace Maui.Controls.Sample.Issues
{

[Issue(IssueTracker.Github, 18423, "[Windows] Shell flyout template items do not have a margin applied on first show", PlatformAffected.UWP)]
public partial class Issue18423Shell : Shell
{
public Issue18423Shell()
{
FlyoutBehavior = FlyoutBehavior.Flyout;

ItemTemplate = new DataTemplate(() =>
{
return new Label
{
AutomationId = "LabelWithMargin",
Margin = new Thickness(20),
Text = "Title"
};
});

ShellContent shellContent = new ShellContent
{
Title = "Home",
ContentTemplate = new DataTemplate(typeof(Issue18423Page)),
Route = "MainPage"
};

Items.Add(shellContent);
}
}

public partial class Issue18423Page : ContentPage
{
public Issue18423Page()
{
BackgroundColor = Colors.HotPink;
this.AutomationId = "MainPage";
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue18423 : _IssuesUITest
{
public Issue18423(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "[Windows] Shell flyout template items do not have a margin applied on first show";

[Test]
[Category(UITestCategories.Shell)]
public void VerifyTemplateViewMarginOnInitialDisplay()
{
App.WaitForElement("MainPage");
App.TapShellFlyoutIcon();
App.WaitForElement("LabelWithMargin");
VerifyScreenshot();
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 290749b

Please sign in to comment.