diff --git a/src/Controls/samples/Controls.Sample.UITests/Issues/Issue7823.xaml b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue7823.xaml
new file mode 100644
index 000000000000..b0e50ab9cf92
--- /dev/null
+++ b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue7823.xaml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Controls/samples/Controls.Sample.UITests/Issues/Issue7823.xaml.cs b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue7823.xaml.cs
new file mode 100644
index 000000000000..672745556fac
--- /dev/null
+++ b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue7823.xaml.cs
@@ -0,0 +1,35 @@
+using System;
+using Microsoft.Maui.Controls;
+using Microsoft.Maui.Controls.Xaml;
+using Microsoft.Maui.Platform;
+
+namespace Maui.Controls.Sample.Issues
+{
+ [XamlCompilation(XamlCompilationOptions.Compile)]
+ [Issue(IssueTracker.Github, 7823, "In a ToolbarItems, if an item has no icon but just text, MAUI uses the icon from the previous page in the Navigation", PlatformAffected.Android)]
+ public class Issue7823NavigationPage : NavigationPage
+ {
+ public Issue7823NavigationPage() : base(new Issue7823())
+ {
+
+ }
+ }
+
+ public partial class Issue7823 : ContentPage
+ {
+ public Issue7823()
+ {
+ InitializeComponent();
+ }
+
+ async void OnToolbarItemClicked(object sender, EventArgs e)
+ {
+ await Navigation.PushAsync(new Issue7823Page2());
+ }
+
+ async void OnButtonClicked(object sender, EventArgs e)
+ {
+ await Navigation.PushAsync(new Issue7823Page2());
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/samples/Controls.Sample.UITests/Issues/Issue7823Page2.xaml b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue7823Page2.xaml
new file mode 100644
index 000000000000..2ff5ed291897
--- /dev/null
+++ b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue7823Page2.xaml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Controls/samples/Controls.Sample.UITests/Issues/Issue7823Page2.xaml.cs b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue7823Page2.xaml.cs
new file mode 100644
index 000000000000..0b3d4425c851
--- /dev/null
+++ b/src/Controls/samples/Controls.Sample.UITests/Issues/Issue7823Page2.xaml.cs
@@ -0,0 +1,21 @@
+using System;
+using Microsoft.Maui.Controls;
+using Microsoft.Maui.Controls.Xaml;
+using Microsoft.Maui.Platform;
+
+namespace Maui.Controls.Sample.Issues
+{
+ [XamlCompilation(XamlCompilationOptions.Compile)]
+ public partial class Issue7823Page2 : ContentPage
+ {
+ public Issue7823Page2()
+ {
+ InitializeComponent();
+ }
+
+ async void OnToolbarItemClicked(object sender, EventArgs e)
+ {
+ await Navigation.PopAsync();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/src/Core/Platform/Android/Extensions/ToolbarExtensions.cs b/src/Controls/src/Core/Platform/Android/Extensions/ToolbarExtensions.cs
index 734304b4c29e..f341b1a5f049 100644
--- a/src/Controls/src/Core/Platform/Android/Extensions/ToolbarExtensions.cs
+++ b/src/Controls/src/Core/Platform/Android/Extensions/ToolbarExtensions.cs
@@ -377,6 +377,10 @@ internal static void UpdateMenuItemIcon(this IMauiContext mauiContext, IMenuItem
menuItem.SetIcon(iconDrawable);
}
}
+ else
+ {
+ menuItem.SetIcon(null);
+ }
});
}
diff --git a/src/Controls/tests/UITests/Tests/Issues/Issue7823.cs b/src/Controls/tests/UITests/Tests/Issues/Issue7823.cs
new file mode 100644
index 000000000000..87d00ce76145
--- /dev/null
+++ b/src/Controls/tests/UITests/Tests/Issues/Issue7823.cs
@@ -0,0 +1,29 @@
+using NUnit.Framework;
+using OpenQA.Selenium;
+using UITest.Appium;
+using UITest.Core;
+
+namespace Microsoft.Maui.AppiumTests.Issues
+{
+ public class Issue7823 : _IssuesUITest
+ {
+ public Issue7823(TestDevice device)
+ : base(device)
+ { }
+
+ public override string Issue => "In a ToolbarItems, if an item has no icon but just text, MAUI uses the icon from the previous page in the Navigation";
+
+ [Test]
+ public void UpdateToolbarItemAfterNavigate()
+ {
+ // 1. Navigate from Page with a ToolbarItem using an Icon.
+ App.WaitForElement("WaitForStubControl");
+ App.Tap("WaitForStubControl");
+
+ App.WaitForElement("SecondPageLoaded");
+
+ // 2. Verify that the second page with a ToolbarItem without an icon does not show the icon of the previous page.
+ VerifyScreenshot();
+ }
+ }
+}
diff --git a/src/Controls/tests/UITests/snapshots/android/UpdateToolbarItemAfterNavigate.png b/src/Controls/tests/UITests/snapshots/android/UpdateToolbarItemAfterNavigate.png
new file mode 100644
index 000000000000..869e724f87f6
Binary files /dev/null and b/src/Controls/tests/UITests/snapshots/android/UpdateToolbarItemAfterNavigate.png differ
diff --git a/src/Controls/tests/UITests/snapshots/ios/UpdateToolbarItemAfterNavigate.png b/src/Controls/tests/UITests/snapshots/ios/UpdateToolbarItemAfterNavigate.png
new file mode 100644
index 000000000000..ea8cb93ee33f
Binary files /dev/null and b/src/Controls/tests/UITests/snapshots/ios/UpdateToolbarItemAfterNavigate.png differ
diff --git a/src/Controls/tests/UITests/snapshots/windows/UpdateToolbarItemAfterNavigate.png b/src/Controls/tests/UITests/snapshots/windows/UpdateToolbarItemAfterNavigate.png
new file mode 100644
index 000000000000..460eb04e4afd
Binary files /dev/null and b/src/Controls/tests/UITests/snapshots/windows/UpdateToolbarItemAfterNavigate.png differ