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] Fix for issues caused by setting Shell.FlyoutWidth on WinUI when binding context values are changed #27151

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
Expand Up @@ -128,13 +128,14 @@ void ShellElementPropertyChanged(object sender, PropertyChangedEventArgs e)

protected override global::Windows.Foundation.Size ArrangeOverride(global::Windows.Foundation.Size finalSize)
{
base.ArrangeOverride(finalSize);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could include an UITest and use get the Label counter value to validate it with an Assert?

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, ensuring this through an assert was not functioning properly in this scenario, possibly because the text only disappeared from the view. As a result, the test passed without this fix. I have added a UI test with VerifyScreenshot to address the issue. Could you please review it and share your feedback?


if (this.ActualWidth > 0 && _content is IView view)
{
view.Arrange(new Rect(0, 0, finalSize.Width, finalSize.Height));
return finalSize;
}

return base.ArrangeOverride(finalSize);
return finalSize;
}

void UpdateVisualState()
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue19496.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
namespace Maui.Controls.Sample.Issues
{
[Issue(IssueTracker.Github, 19496, "The Shell item text disappears when it is updated dynamically at runtime", PlatformAffected.UWP)]
public partial class Issue19496 : TestShell
{
int count = 0;
protected override void Init()
{
FlyoutBackgroundColor = Colors.Gray;
FlyoutWidth = 85;
FlyoutBehavior = FlyoutBehavior.Locked;

Label label = new Label
{
Text = count.ToString(),
AutomationId = "FlyoutItemLabel",
TextColor = Colors.White
};

ContentPage contentPage = new ContentPage();

contentPage.Content = new Button()
{
Text = "Update Label Text",
AutomationId = "button",
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center,
Command = new Command(() =>
{
count++;
label.Text = count.ToString();
})
};

DataTemplate dataTemplate = new DataTemplate(() =>
{

return label;
});

this.ItemTemplate = dataTemplate;

base.AddFlyoutItem(contentPage, "MainPage");
}
}
}
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,27 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue19496 : _IssuesUITest
{
public override string Issue => "The Shell item text disappears when it is updated dynamically at runtime";

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

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