Skip to content

Commit 63101a9

Browse files
NirmalKumarYuvarajPureWeen
authored andcommitted
[Windows] Fixed BarTextColor applied to secondary toolbar items (#28932)
* Fixed bar textcolor used in secondary toolbar * Update MauiToolbar.xaml.cs * resolved the changes * Update Issue20177.cs * modified issue string * added windows snapshot
1 parent 76e32c6 commit 63101a9

File tree

4 files changed

+80
-2
lines changed

4 files changed

+80
-2
lines changed

src/Controls/src/Core/Toolbar/Toolbar.Windows.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,12 @@ internal void UpdateMenu()
6565
button.SetAutomationPropertiesName(item);
6666
button.SetAutomationPropertiesAccessibilityView(item);
6767
button.SetAutomationPropertiesHelpText(item);
68-
button.UpdateTextColor(BarTextColor);
69-
7068
button.SetAutomationPropertiesLabeledBy(item, null);
7169

7270
ToolbarItemOrder order = item.Order == ToolbarItemOrder.Default ? ToolbarItemOrder.Primary : item.Order;
7371
if (order == ToolbarItemOrder.Primary)
7472
{
73+
button.UpdateTextColor(BarTextColor);
7574
commandBar.PrimaryCommands.Add(button);
7675
}
7776
else
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
namespace Maui.Controls.Sample.Issues;
2+
3+
[Issue(IssueTracker.Github, 20177, "Shell TitleColor changes the secondary ToolbarItems TextColor", PlatformAffected.UWP)]
4+
public class Issue20177 : TestShell
5+
{
6+
protected override void Init()
7+
{
8+
Shell.SetTitleColor(this, Colors.White);
9+
AddContentPage(CreateContentPage());
10+
}
11+
12+
ContentPage CreateContentPage()
13+
{
14+
var page = new ContentPage();
15+
PopulateToolBarItems(page);
16+
page.Content = CreateGrid();
17+
return page;
18+
}
19+
20+
Grid CreateGrid()
21+
{
22+
Grid grid = new Grid()
23+
{
24+
new Label()
25+
{
26+
HorizontalOptions = LayoutOptions.Center,
27+
VerticalOptions= LayoutOptions.Center,
28+
Text = "Secondary ToolBar Items should not use BarTextColor",
29+
AutomationId = "DescriptionLabel"
30+
}
31+
};
32+
return grid;
33+
}
34+
35+
void PopulateToolBarItems(ContentPage page)
36+
{
37+
page.ToolbarItems.Add(new()
38+
{
39+
Text = "Menu item",
40+
Order = ToolbarItemOrder.Primary
41+
});
42+
page.ToolbarItems.Add(new()
43+
{
44+
Text = "Menu item 1",
45+
Order = ToolbarItemOrder.Secondary
46+
});
47+
page.ToolbarItems.Add(new()
48+
{
49+
Text = "Menu item 2",
50+
Order = ToolbarItemOrder.Secondary
51+
});
52+
page.ToolbarItems.Add(new()
53+
{
54+
Text = "Menu item 3",
55+
Order = ToolbarItemOrder.Secondary
56+
});
57+
}
58+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#if WINDOWS // Issue can be repro on windows only
2+
using NUnit.Framework;
3+
using UITest.Appium;
4+
using UITest.Core;
5+
6+
namespace Microsoft.Maui.TestCases.Tests.Issues;
7+
internal class Issue20177 : _IssuesUITest
8+
{
9+
public Issue20177(TestDevice device) : base(device) { }
10+
11+
public override string Issue => "Shell TitleColor changes the secondary ToolbarItems TextColor";
12+
13+
[Test]
14+
[Category(UITestCategories.ToolbarItem)]
15+
public void ToolBarSecondayItemsShouldNotUseBarTextColor()
16+
{
17+
App.ToggleSecondaryToolbarItems();
18+
VerifyScreenshot();
19+
}
20+
}
21+
#endif
10.6 KB
Loading

0 commit comments

Comments
 (0)