-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fixed Shell Navigating event issue when switching tabs #25749
Draft
Vignesh-SF3580
wants to merge
2
commits into
dotnet:main
Choose a base branch
from
Vignesh-SF3580:fix-25599
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+116
−3
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
37 changes: 37 additions & 0 deletions
37
src/Controls/tests/TestCases.HostApp/Issues/Issue25599.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,37 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<Shell xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Maui.Controls.Sample.Issues.Issue25599" | ||
xmlns:local="clr-namespace:Maui.Controls.Sample.Issues"> | ||
<TabBar Shell.TabBarForegroundColor="Green" | ||
Shell.TabBarUnselectedColor="Red"> | ||
<Tab Title="Home" x:Name="FirstTab"> | ||
<ShellContent | ||
Title="Home" > | ||
<ShellContent.ContentTemplate> | ||
<DataTemplate> | ||
<ContentPage x:Name="firstPage"> | ||
<StackLayout> | ||
<Button Text="Click" Clicked="Button_Clicked" AutomationId="HomePageButton"/> | ||
<Label Text="Home Page" AutomationId="HomePageLabel"/> | ||
</StackLayout> | ||
</ContentPage> | ||
</DataTemplate> | ||
</ShellContent.ContentTemplate> | ||
</ShellContent> | ||
</Tab> | ||
<Tab Title="Settings" x:Name="SecondTab"> | ||
<ShellContent> | ||
<ShellContent.ContentTemplate> | ||
<DataTemplate> | ||
<ContentPage x:Name="secondPage"> | ||
<StackLayout> | ||
<Label x:Name="settingsPageLabel" Text="SettingsPage" /> | ||
</StackLayout> | ||
</ContentPage> | ||
</DataTemplate> | ||
</ShellContent.ContentTemplate> | ||
</ShellContent> | ||
</Tab> | ||
</TabBar> | ||
</Shell> |
35 changes: 35 additions & 0 deletions
35
src/Controls/tests/TestCases.HostApp/Issues/Issue25599.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 @@ | ||
namespace Maui.Controls.Sample.Issues; | ||
|
||
[Issue(IssueTracker.Github, 25599, "OnNavigating wrong target when tapping the same tab", PlatformAffected.iOS)] | ||
public partial class Issue25599 : Shell | ||
{ | ||
public Issue25599() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private async void Button_Clicked(object sender, EventArgs e) | ||
{ | ||
await Navigation.PushAsync(new DetailsPage()); | ||
} | ||
|
||
public class DetailsPage : ContentPage | ||
{ | ||
public DetailsPage() | ||
{ | ||
Title = "DetailsPage"; | ||
|
||
Content = new StackLayout | ||
{ | ||
Children = | ||
{ | ||
new Label | ||
{ | ||
Text = "Details Page", | ||
AutomationId = "DetailsPageLabel" | ||
} | ||
} | ||
}; | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue25599.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,27 @@ | ||
#if ANDROID // Facing a full exception when clicking on the already selected tab(App.Tap()) in Windows, iOS, and macOS, so excluded those platforms. | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.TestCases.Tests.Issues | ||
{ | ||
public class Issue25599 : _IssuesUITest | ||
{ | ||
public Issue25599(TestDevice testDevice) : base(testDevice){ } | ||
|
||
public override string Issue => "OnNavigating wrong target when tapping the same tab"; | ||
|
||
[Test] | ||
[Category(UITestCategories.Navigation)] | ||
public void NavigatingEventFired() | ||
{ | ||
App.WaitForElement("HomePageButton"); | ||
App.Tap("HomePageButton"); | ||
App.WaitForElement("DetailsPageLabel"); | ||
App.Tap("Home"); | ||
App.WaitForElement("DetailsPageLabel"); | ||
App.WaitForNoElement("HomePageLabel"); //Navigation does not occur when clicking on an already selected tab | ||
} | ||
} | ||
} | ||
#endif |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could include an UITest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added the test case. Could you please review it and let me know if you have any concerns?