Skip to content

Commit 50a8a83

Browse files
[Windows] Fix for issues caused by setting Shell.FlyoutWidth on WinUI when binding context values are changed (#27151)
* Fixed FlyoutItem issue * Fixed Flyout Issues. * Added test case. * Added snapshot for WinUI and Mac * Revert changes
1 parent 027f757 commit 50a8a83

File tree

7 files changed

+76
-2
lines changed

7 files changed

+76
-2
lines changed

src/Controls/src/Core/Handlers/Shell/Windows/ShellFlyoutItemView.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,16 @@ void ShellElementPropertyChanged(object sender, PropertyChangedEventArgs e)
128128

129129
protected override global::Windows.Foundation.Size ArrangeOverride(global::Windows.Foundation.Size finalSize)
130130
{
131+
base.ArrangeOverride(finalSize);
132+
131133
// Replaced ActualWidth with finalSize.Width since ActualWidth updates only after ArrangeOverride completes,
132134
// ensuring accurate layout during the initial arrangement phase.
133135
if (finalSize.Width > 0 && _content is IView view)
134136
{
135137
view.Arrange(new Rect(0, 0, finalSize.Width, finalSize.Height));
136-
return finalSize;
137138
}
138139

139-
return base.ArrangeOverride(finalSize);
140+
return finalSize;
140141
}
141142

142143
void UpdateVisualState()
24 KB
Loading
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
namespace Maui.Controls.Sample.Issues
2+
{
3+
[Issue(IssueTracker.Github, 19496, "The Shell item text disappears when it is updated dynamically at runtime", PlatformAffected.UWP)]
4+
public partial class Issue19496 : TestShell
5+
{
6+
int count = 0;
7+
protected override void Init()
8+
{
9+
FlyoutBackgroundColor = Colors.Gray;
10+
FlyoutWidth = 85;
11+
FlyoutBehavior = FlyoutBehavior.Locked;
12+
13+
Label label = new Label
14+
{
15+
Text = count.ToString(),
16+
AutomationId = "FlyoutItemLabel",
17+
TextColor = Colors.White
18+
};
19+
20+
ContentPage contentPage = new ContentPage();
21+
22+
contentPage.Content = new Button()
23+
{
24+
Text = "Update Label Text",
25+
AutomationId = "button",
26+
HorizontalOptions = LayoutOptions.Center,
27+
VerticalOptions = LayoutOptions.Center,
28+
Command = new Command(() =>
29+
{
30+
count++;
31+
label.Text = count.ToString();
32+
})
33+
};
34+
35+
DataTemplate dataTemplate = new DataTemplate(() =>
36+
{
37+
38+
return label;
39+
});
40+
41+
this.ItemTemplate = dataTemplate;
42+
43+
base.AddFlyoutItem(contentPage, "MainPage");
44+
}
45+
}
46+
}
48.8 KB
Loading
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using NUnit.Framework;
2+
using UITest.Appium;
3+
using UITest.Core;
4+
5+
namespace Microsoft.Maui.TestCases.Tests.Issues
6+
{
7+
public class Issue19496 : _IssuesUITest
8+
{
9+
public override string Issue => "The Shell item text disappears when it is updated dynamically at runtime";
10+
11+
public Issue19496(TestDevice device)
12+
: base(device)
13+
{ }
14+
15+
[Test]
16+
[Category(UITestCategories.Shell)]
17+
public void FlyoutItemTextShouldDisplayProperly()
18+
{
19+
App.WaitForElement("button");
20+
App.Tap("button");
21+
App.Tap("button");
22+
App.Tap("button");
23+
App.Tap("button");
24+
VerifyScreenshot();
25+
}
26+
}
27+
}
8.65 KB
Loading
25.2 KB
Loading

0 commit comments

Comments
 (0)