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
17 changes: 17 additions & 0 deletions src/Controls/samples/Controls.Sample.UITests/Issues/Issue7823.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue7823">
<ContentPage.ToolbarItems>
<ToolbarItem
IconImageSource="dotnet_bot.png"
Clicked="OnToolbarItemClicked"/>
</ContentPage.ToolbarItems>
<StackLayout
Padding="12">
<Button
AutomationId="WaitForStubControl"
Text="Navigate"
Clicked="OnButtonClicked" />
</StackLayout>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -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());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue7823Page2">
<ContentPage.ToolbarItems>
<ToolbarItem
Text="Test"
Clicked="OnToolbarItemClicked"/>
</ContentPage.ToolbarItems>
<Grid>
<Label
AutomationId="SecondPageLoaded"
HorizontalOptions="Center"
VerticalOptions="Center"
Text="Issue 7823" />
</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,10 @@ internal static void UpdateMenuItemIcon(this IMauiContext mauiContext, IMenuItem
menuItem.SetIcon(iconDrawable);
}
}
else
{
menuItem.SetIcon(null);
}
});
}

Expand Down
29 changes: 29 additions & 0 deletions src/Controls/tests/UITests/Tests/Issues/Issue7823.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.