Skip to content

[Windows] Fixed BarTextColor applied to secondary toolbar items #28932

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

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
3 changes: 1 addition & 2 deletions src/Controls/src/Core/Toolbar/Toolbar.Windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,12 @@ internal void UpdateMenu()
button.SetAutomationPropertiesName(item);
button.SetAutomationPropertiesAccessibilityView(item);
button.SetAutomationPropertiesHelpText(item);
button.UpdateTextColor(BarTextColor);

button.SetAutomationPropertiesLabeledBy(item, null);

ToolbarItemOrder order = item.Order == ToolbarItemOrder.Default ? ToolbarItemOrder.Primary : item.Order;
if (order == ToolbarItemOrder.Primary)
{
button.UpdateTextColor(BarTextColor);
commandBar.PrimaryCommands.Add(button);
}
else
Expand Down
58 changes: 58 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue20177.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 20177, "Shell TitleColor changes the secondary ToolbarItems TextColor", PlatformAffected.UWP)]
public class Issue20177 : TestShell
{
protected override void Init()
{
Shell.SetTitleColor(this, Colors.White);
AddContentPage(CreateContentPage());
}

ContentPage CreateContentPage()
{
var page = new ContentPage();
PopulateToolBarItems(page);
page.Content = CreateGrid();
return page;
}

Grid CreateGrid()
{
Grid grid = new Grid()
{
new Label()
{
HorizontalOptions = LayoutOptions.Center,
VerticalOptions= LayoutOptions.Center,
Text = "Secondary ToolBar Items should not use BarTextColor",
AutomationId = "DescriptionLabel"
}
};
return grid;
}

void PopulateToolBarItems(ContentPage page)
{
page.ToolbarItems.Add(new()
{
Text = "Menu item",
Order = ToolbarItemOrder.Primary
});
page.ToolbarItems.Add(new()
{
Text = "Menu item 1",
Order = ToolbarItemOrder.Secondary
});
page.ToolbarItems.Add(new()
{
Text = "Menu item 2",
Order = ToolbarItemOrder.Secondary
});
page.ToolbarItems.Add(new()
{
Text = "Menu item 3",
Order = ToolbarItemOrder.Secondary
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#if WINDOWS // Issue can be repro on windows only
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;
internal class Issue20177 : _IssuesUITest
{
public Issue20177(TestDevice device) : base(device) { }

public override string Issue => "Shell TitleColor changes the secondary ToolbarItems TextColor";

[Test]
[Category(UITestCategories.ToolbarItem)]
public void ToolBarSecondayItemsShouldNotUseBarTextColor()
{
App.ToggleSecondaryToolbarItems();
VerifyScreenshot();
}
}
#endif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.