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

[Windows] Fixed Margin Not Applied to Shell Flyout Template Items on First Display #27060

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
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.Content = new Label() { AutomationId = "MainPageLabel", Text = "Content" };
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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()
Copy link
Contributor

Choose a reason for hiding this comment

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

The test is failing on Windows:

System.TimeoutException : Timed out waiting for element...

   at UITest.Appium.HelperExtensions.Wait(Func`1 query, Func`2 satisfactory, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 2163
   at UITest.Appium.HelperExtensions.WaitForAtLeastOne(Func`1 query, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 2180
   at UITest.Appium.HelperExtensions.WaitForElement(IApp app, String marked, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency, Nullable`1 postTimeout) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 665
   at Microsoft.Maui.TestCases.Tests.Issues.Issue18423.VerifyTemplateViewMarginOnInitialDisplay() in /_/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue18423.cs:line 19
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test is failing on Windows:

System.TimeoutException : Timed out waiting for element...

   at UITest.Appium.HelperExtensions.Wait(Func`1 query, Func`2 satisfactory, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 2163
   at UITest.Appium.HelperExtensions.WaitForAtLeastOne(Func`1 query, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 2180
   at UITest.Appium.HelperExtensions.WaitForElement(IApp app, String marked, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency, Nullable`1 postTimeout) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 665
   at Microsoft.Maui.TestCases.Tests.Issues.Issue18423.VerifyTemplateViewMarginOnInitialDisplay() in /_/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue18423.cs:line 19
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

@jsuarezruiz , Thank you for pointing this out. Addressed the issue by updating the test logic and believe it will not fail in the next CI run.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, thanks. The Windows snapshot is pending, could you commit it? Available in the latest build.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jsuarezruiz Thanks! The pending Windows snapshot has been added.

{
App.WaitForElement("MainPageLabel");
App.TapShellFlyoutIcon();
VerifyScreenshot();
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading