Skip to content
Merged
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 @@ -107,7 +107,10 @@ protected virtual void HandleShellPropertyChanged(object sender, PropertyChanged
if (e.Is(VisualElement.FlowDirectionProperty))
UpdateFlowDirection();
else if (e.Is(Shell.FlyoutIconProperty) || e.Is(Shell.ForegroundColorProperty))
{
UpdateLeftToolbarItems();
UpdateRightBarButtonItemTintColors();
}
}

#nullable disable
Expand Down Expand Up @@ -154,6 +157,7 @@ protected virtual void OnPagePropertyChanged(object sender, PropertyChangedEvent
else if (e.PropertyName == Shell.ForegroundColorProperty.PropertyName)
{
UpdateLeftToolbarItems();
UpdateRightBarButtonItemTintColors();
}
}

Expand Down Expand Up @@ -455,9 +459,37 @@ protected virtual void UpdateToolbarItems()

NavigationItem.SetRightBarButtonItems(primaries is null ? Array.Empty<UIBarButtonItem>() : primaries.ToArray(), false);

UpdateRightBarButtonItemTintColors();
UpdateLeftToolbarItems();
}

/// iOS 26+: LiquidGlass no longer inherits the foreground color from the navigation bar's TintColor.
/// Explicitly set TintColor on each right bar button item to ensure the Shell.ForegroundColor is applied.
void UpdateRightBarButtonItemTintColors()
{
if (!(OperatingSystem.IsIOSVersionAtLeast(26) || OperatingSystem.IsMacCatalystVersionAtLeast(26)))
{
return;
}

if (NavigationItem?.RightBarButtonItems is not { Length: > 0 } rightItems)
{
return;
}

var foregroundColor = _context?.Shell?.CurrentPage?.GetValue(Shell.ForegroundColorProperty) ??
_context?.Shell?.GetValue(Shell.ForegroundColorProperty);

var platformColor = foregroundColor is Graphics.Color shellForegroundColor
? shellForegroundColor.ToPlatform()
: null;

foreach (var item in rightItems)
{
item.TintColor = platformColor;
}
}

void UpdateLeftToolbarItems()
{
var shell = _context?.Shell;
Expand Down
32 changes: 32 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue34083.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 34083, "Toolbar Items Do Not Reflect Shell ForegroundColor", PlatformAffected.iOS)]
public class Issue34083 : Shell
{
public Issue34083()
{
Items.Add(new Issue34083Page());
Shell.SetForegroundColor(this, Colors.Purple);
}

public class Issue34083Page : ContentPage
{
public Issue34083Page()
{
Title = "Home";
ToolbarItems.Add(new ToolbarItem
{
IconImageSource = "calculator.png",
Order = ToolbarItemOrder.Primary
});

Content = new Label
{
Text = "The test passes if the color is being applied to the toolbar.",
AutomationId = "Issue34083_DescriptionLabel",
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center
};
}
}
}
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,24 @@
#if TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_WINDOWS // Android Issue Link: https://github.com/dotnet/maui/issues/24676, Windows Issue Link: https://github.com/dotnet/maui/issues/34071
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

The test includes a preprocessor directive TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_WINDOWS which disables the test on Android and Windows. The comment references two separate issues for Android and Windows failures.

However, this test should NOT fail on these platforms - it's testing iOS-specific behavior (the test page is marked PlatformAffected.iOS). The test should simply not run on Android/Windows.

Consider using a cleaner approach:

  • Remove the TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_WINDOWS directive entirely
  • The test framework should automatically skip tests for platforms not affected based on the PlatformAffected.iOS attribute in the Issue attribute
  • If platform-specific test execution is needed, use #if IOS || MACCATALYST instead

Copilot uses AI. Check for mistakes.
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue34083 : _IssuesUITest
{
public Issue34083(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "Toolbar Items Do Not Reflect Shell ForegroundColor";

[Test]
[Category(UITestCategories.Shell)]
public void VerifyShellForegroundColorIsAppliedToToolbarItems()
{
App.WaitForElement("Issue34083_DescriptionLabel");
VerifyScreenshot();
}
}
#endif
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