-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix text toolbar item icon not removed when navigating on Android (#1…
…6796) * Fix text toolbar item icon not removed when navigating on Android Fixes an issue on Android when there are multiple pages with toolbar items and on one page the toolbar item has an icon and on another page it doesn't, the icon is not removed when navigating to the page without the icon. When updating the Android Menuitem icon and the base drawable is null, the icon is set to null. On Android, this clears out the previous icon. Fixes #7823 * Added UITest * Improve test * - update screenshots * - add windows --------- Co-authored-by: Javier Suárez <javiersuarezruiz@hotmail.com> Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com> Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
- Loading branch information
1 parent
396f7f7
commit a93e88c
Showing
9 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/Controls/samples/Controls.Sample.UITests/Issues/Issue7823.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
35 changes: 35 additions & 0 deletions
35
src/Controls/samples/Controls.Sample.UITests/Issues/Issue7823.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/Controls/samples/Controls.Sample.UITests/Issues/Issue7823Page2.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
21 changes: 21 additions & 0 deletions
21
src/Controls/samples/Controls.Sample.UITests/Issues/Issue7823Page2.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
Binary file added
BIN
+18.8 KB
src/Controls/tests/UITests/snapshots/android/UpdateToolbarItemAfterNavigate.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+25.9 KB
src/Controls/tests/UITests/snapshots/ios/UpdateToolbarItemAfterNavigate.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.79 KB
src/Controls/tests/UITests/snapshots/windows/UpdateToolbarItemAfterNavigate.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.