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 9 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,16 @@ void ShellElementPropertyChanged(object sender, PropertyChangedEventArgs e)

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

// 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;
}

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