-
Notifications
You must be signed in to change notification settings - Fork 2k
[iOS][Android] Shell: Fix tab bar visibility and selection after first tab becomes invisible #34372
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
3b0cf2a
Added test case and ios fix
Shalini-Ashokan 48b2312
Fix the android title not change issue
Shalini-Ashokan 17e69c4
modified the fix
Shalini-Ashokan 69512ba
Fix for issue 34343
Shalini-Ashokan d56eceb
committed the ios image
Shalini-Ashokan bc6dddb
committed the android snapshot
Shalini-Ashokan 160d420
Removed unwanted changes
Shalini-Ashokan 2666689
Removed unwanted changes
Shalini-Ashokan ad92cf1
modified the test
Shalini-Ashokan 0f5c0fc
Removed unwanted changes
Shalini-Ashokan 3dc103e
Addressed the copilot concern
Shalini-Ashokan bb5c74d
Added snapshots
Shalini-Ashokan 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 hidden or 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 hidden or 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
Binary file added
BIN
+34.1 KB
...apshots/android/TabBarShouldDisplayCorrectTabsAfterFirstTabBecomesInvisible.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
146 changes: 146 additions & 0 deletions
146
src/Controls/tests/TestCases.HostApp/Issues/Issue34343.cs
This file contains hidden or 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,146 @@ | ||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 34343, "TabBar displays wrong tabs after first tab becomes invisible", PlatformAffected.Android | PlatformAffected.iOS)] | ||
| public class Issue34343 : Shell | ||
| { | ||
| ContentPage _tab1Page; | ||
| public Issue34343() | ||
| { | ||
| Routing.RegisterRoute("Page51", typeof(Issue34343_Page51)); | ||
|
|
||
| var tabBar = new TabBar(); | ||
| var button = new Button | ||
| { | ||
| Text = "Hide Tab1 and Go to Tab5", | ||
| AutomationId = "HideAndNavigateButton", | ||
| }; | ||
|
|
||
| _tab1Page = new ContentPage | ||
| { | ||
| Title = "Tab1", | ||
| Content = new VerticalStackLayout | ||
| { | ||
| Children = { button } | ||
| } | ||
| }; | ||
|
|
||
| button.Clicked += async (s, e) => | ||
| { | ||
| // Setting IsVisible = false on the page (as in the issue repro: "this.IsVisible = false") | ||
| _tab1Page.IsVisible = false; | ||
| await Shell.Current.GoToAsync("///Tab5"); | ||
| }; | ||
|
|
||
| var tab1Content = new ShellContent | ||
| { | ||
| Title = "Tab1", | ||
| Route = "Tab1", | ||
| Content = _tab1Page | ||
| }; | ||
|
|
||
| var tab1 = new Tab { Title = "Tab1", AutomationId = "Tab1" }; | ||
| tab1.Items.Add(tab1Content); | ||
| tabBar.Items.Add(tab1); | ||
|
|
||
| for (int i = 2; i <= 4; i++) | ||
| { | ||
| int tabNum = i; | ||
| var content = new ShellContent | ||
| { | ||
| Title = $"Tab{tabNum}", | ||
| Route = $"Tab{tabNum}", | ||
| ContentTemplate = new DataTemplate(() => new ContentPage | ||
| { | ||
| Title = $"Tab{tabNum}", | ||
| Content = new Label | ||
| { | ||
| Text = $"Tab{tabNum} Content", | ||
| AutomationId = $"Tab{tabNum}Content", | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| VerticalOptions = LayoutOptions.Center | ||
| } | ||
| }) | ||
| }; | ||
| var tab = new Tab { Title = $"Tab{tabNum}", AutomationId = $"Tab{tabNum}" }; | ||
| tab.Items.Add(content); | ||
| tabBar.Items.Add(tab); | ||
| } | ||
|
|
||
| // Tab 5 - has a button to navigate to Page51 (iOS repro: relative sub-page navigation) | ||
| var navigateToPage51Button = new Button | ||
| { | ||
| Text = "Navigate to Page51", | ||
| AutomationId = "NavigateToPage51Button", | ||
| }; | ||
| navigateToPage51Button.Clicked += async (s, e) => | ||
| { | ||
| await Shell.Current.GoToAsync("Page51"); | ||
| }; | ||
|
|
||
| var tab5Page = new ContentPage | ||
| { | ||
| Title = "Tab5", | ||
| Content = new VerticalStackLayout | ||
| { | ||
| VerticalOptions = LayoutOptions.Center, | ||
| Children = | ||
| { | ||
| new Label | ||
| { | ||
| Text = "Tab5 Content", | ||
| AutomationId = "Tab5Content", | ||
| HorizontalOptions = LayoutOptions.Center | ||
| }, | ||
| navigateToPage51Button | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| var tab5Content = new ShellContent { Title = "Tab5", Route = "Tab5", Content = tab5Page }; | ||
| var tab5 = new Tab { Title = "Tab5", AutomationId = "Tab5" }; | ||
| tab5.Items.Add(tab5Content); | ||
| tabBar.Items.Add(tab5); | ||
|
|
||
| for (int i = 6; i <= 7; i++) | ||
| { | ||
| int tabNum = i; | ||
| var content = new ShellContent | ||
| { | ||
| Title = $"Tab{tabNum}", | ||
| Route = $"Tab{tabNum}", | ||
| ContentTemplate = new DataTemplate(() => new ContentPage | ||
| { | ||
| Title = $"Tab{tabNum}", | ||
| Content = new Label | ||
| { | ||
| Text = $"Tab{tabNum} Content", | ||
| AutomationId = $"Tab{tabNum}Content", | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| VerticalOptions = LayoutOptions.Center | ||
| } | ||
| }) | ||
| }; | ||
| var tab = new Tab { Title = $"Tab{tabNum}", AutomationId = $"Tab{tabNum}" }; | ||
| tab.Items.Add(content); | ||
| tabBar.Items.Add(tab); | ||
| } | ||
|
|
||
| Items.Add(tabBar); | ||
| } | ||
| } | ||
|
|
||
| // Sub-page navigated to from Tab5 (relative route "Page51") | ||
| public class Issue34343_Page51 : ContentPage | ||
| { | ||
| public Issue34343_Page51() | ||
| { | ||
| Title = "Page51"; | ||
| Content = new Label | ||
| { | ||
| Text = "Page51 Content", | ||
| AutomationId = "Page51Content", | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| VerticalOptions = LayoutOptions.Center | ||
| }; | ||
| } | ||
| } |
Binary file added
BIN
+11.7 KB
...ests/snapshots/mac/SubPageNavigationShouldWorkAfterFirstTabBecomesInvisible.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions
37
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34343.cs
This file contains hidden or 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 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue34343 : _IssuesUITest | ||
| { | ||
| public override string Issue => "TabBar displays wrong tabs after first tab becomes invisible"; | ||
|
|
||
| public Issue34343(TestDevice device) : base(device) { } | ||
|
|
||
| #if ANDROID | ||
| [Test] | ||
| [Category(UITestCategories.Shell)] | ||
| public void TabBarShouldDisplayCorrectTabsAfterFirstTabBecomesInvisible() | ||
| { | ||
| App.WaitForElement("HideAndNavigateButton"); | ||
| App.Tap("HideAndNavigateButton"); | ||
| App.WaitForElement("Tab5Content"); | ||
| VerifyScreenshot(); | ||
| } | ||
| #endif | ||
|
|
||
| #if IOS || MACCATALYST | ||
| [Test] | ||
| [Category(UITestCategories.Shell)] | ||
| public void SubPageNavigationShouldWorkAfterFirstTabBecomesInvisible() | ||
| { | ||
| App.WaitForElement("HideAndNavigateButton"); | ||
| App.Tap("HideAndNavigateButton"); | ||
| App.WaitForElement("Tab5Content"); | ||
| App.Tap("NavigateToPage51Button"); | ||
| VerifyScreenshot(); | ||
| } | ||
| #endif | ||
| } | ||
Binary file added
BIN
+52.7 KB
...s/snapshots/ios-26/SubPageNavigationShouldWorkAfterFirstTabBecomesInvisible.png
Loading
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
+36.8 KB
...ests/snapshots/ios/SubPageNavigationShouldWorkAfterFirstTabBecomesInvisible.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.