-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Android] Fixed incorrect tab content display in TabbedPage #27294
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
7 commits
Select commit
Hold shift + click to select a range
8440636
updated TabbedPageManager.cs
Vignesh-SF3580 4784b24
issue fixed and testcases updated.
Vignesh-SF3580 6f94cab
updated Issue23732.cs
Vignesh-SF3580 f9d9864
updated testcases.
Vignesh-SF3580 9754265
updated the testcase by removing the DisconnectHandler.
Vignesh-SF3580 5d5e153
updated testcases.
Vignesh-SF3580 0f67bd4
21640 testcases added.
Vignesh-SF3580 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
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
30 changes: 30 additions & 0 deletions
30
src/Controls/tests/TestCases.HostApp/Issues/23732Page.xaml
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,30 @@ | ||
| <?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._23732Page" | ||
| xmlns:local="clr-namespace:Maui.Controls.Sample.Issues"> | ||
|
|
||
| <Grid RowDefinitions="Auto,*"> | ||
| <CollectionView | ||
| Grid.Row="1" | ||
| Margin="0,20" | ||
| ItemsSource="{Binding Models}"> | ||
| <CollectionView.ItemTemplate> | ||
| <DataTemplate> | ||
| <Grid | ||
| BackgroundColor="Gray" | ||
| HeightRequest="60" | ||
| ColumnDefinitions="*,Auto"> | ||
| <BoxView Grid.ColumnSpan="2" Color="White"/> | ||
| <Label | ||
| Margin="20,0" | ||
| Text="Item" | ||
| VerticalOptions="Center" | ||
| TextColor="Blue"/> | ||
| <BoxView Grid.ColumnSpan="2"/> | ||
| </Grid> | ||
| </DataTemplate> | ||
| </CollectionView.ItemTemplate> | ||
| </CollectionView> | ||
| </Grid> | ||
| </ContentPage> |
68 changes: 68 additions & 0 deletions
68
src/Controls/tests/TestCases.HostApp/Issues/23732Page.xaml.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,68 @@ | ||
| using System.Collections.ObjectModel; | ||
|
|
||
| namespace Maui.Controls.Sample.Issues | ||
| { | ||
| public partial class _23732Page : ContentPage | ||
| { | ||
| public ObservableCollection<string> Models { get; } = new(); | ||
| public _23732Page(bool isPage4) | ||
| { | ||
| InitializeComponent(); | ||
| BindingContext = this; | ||
| for (int i = 0; i <= 6; i++) | ||
| { | ||
| Models.Add(string.Empty); | ||
| } | ||
|
|
||
| if (isPage4) | ||
| { | ||
| var label = new Label | ||
| { | ||
| Text = "page4", | ||
| AutomationId = "label", | ||
| HorizontalTextAlignment = TextAlignment.Center | ||
| }; | ||
| (Content as Grid)?.Children.Insert(0, label); | ||
| } | ||
| } | ||
|
|
||
| private string _label; | ||
| public string Label | ||
| { | ||
| get => _label; | ||
| set | ||
| { | ||
| if (_label != value) | ||
| { | ||
| _label = value; | ||
| OnPropertyChanged(); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| [Issue(IssueTracker.Github, 23732, "TabBar content not displayed properly", PlatformAffected.Android)] | ||
| public partial class Issue23732 : TabbedPage | ||
| { | ||
| public Issue23732() | ||
| { | ||
| for (int i = 1; i <= 5; i++) | ||
| { | ||
| Children.Add(CreateNavigationPage($"Page {i}", $"page{i}")); | ||
| } | ||
| } | ||
|
|
||
| private NavigationPage CreateNavigationPage(string title, string label) | ||
| { | ||
| var mainPage = new _23732Page(label == "page4") | ||
| { | ||
| Label = label | ||
| }; | ||
|
|
||
| return new NavigationPage(mainPage) | ||
| { | ||
| Title = title | ||
| }; | ||
| } | ||
| } | ||
| } |
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,65 @@ | ||
| namespace Maui.Controls.Sample.Issues | ||
| { | ||
| [Issue(IssueTracker.Github, 21640, "TabbedPage content was not updated", PlatformAffected.Android)] | ||
| public partial class Issue21640 : TabbedPage | ||
| { | ||
| private Page _savedPage; | ||
| public Issue21640() | ||
| { | ||
| var homePage = new ContentPage | ||
| { | ||
| Title = "Home", | ||
| Content = new Button | ||
| { | ||
| Text = "Toggle Tab", | ||
| Command = new Command(ToggleTab), | ||
| AutomationId = "ToogleTabButton" | ||
| } | ||
| }; | ||
|
|
||
| var newPage = CreateNewPage(); | ||
| _savedPage = new NavigationPage(newPage) { Title = "Settings" }; | ||
| Children.Add(new NavigationPage(homePage) { Title = "Home" }); | ||
| } | ||
|
|
||
| private async void ToggleTab() | ||
| { | ||
| if (Children.Count == 1) | ||
| { | ||
| await MainThread.InvokeOnMainThreadAsync(() => | ||
| { | ||
| Children.Add(_savedPage); | ||
| }); | ||
| } | ||
| else if (Children.Count == 2) | ||
| { | ||
| _savedPage = Children[1]; | ||
| await MainThread.InvokeOnMainThreadAsync(() => | ||
| { | ||
| Children.RemoveAt(1); | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| private Page CreateNewPage() | ||
| { | ||
| return new ContentPage | ||
| { | ||
| Title = "NewPage", | ||
| Content = new VerticalStackLayout | ||
| { | ||
| Children = | ||
| { | ||
| new Label | ||
| { | ||
| Text = "Welcome to .NET MAUI!", | ||
| VerticalOptions = LayoutOptions.Center, | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| AutomationId = "label" | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| } | ||
| } | ||
| } |
43 changes: 43 additions & 0 deletions
43
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue21640.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,43 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues | ||
| { | ||
| public class Issue21640 : _IssuesUITest | ||
| { | ||
| public Issue21640(TestDevice testDevice) : base(testDevice) | ||
| { | ||
| } | ||
| public override string Issue => "TabbedPage content was not updated"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.TabbedPage)] | ||
| public void TabbedPageContentUpdatesCorrectly() | ||
| { | ||
| #if ANDROID | ||
| string tab1Title = "HOME"; | ||
| string tab2Title = "SETTINGS"; | ||
| #else | ||
| string tab1Title = "Home"; | ||
| string tab2Title = "Settings"; | ||
| #endif | ||
| string toggleTabButtonId = "ToogleTabButton"; | ||
| App.WaitForElement(toggleTabButtonId); | ||
| App.Tap(toggleTabButtonId); | ||
| App.Tap(tab2Title); | ||
| App.WaitForElement("label"); | ||
|
|
||
| // The issue occurs when repeatedly removing and re-adding the tab while navigating between tabs. | ||
| for (int i = 0; i < 3; i++) | ||
| { | ||
| App.Tap(tab1Title); | ||
| App.WaitForElement(toggleTabButtonId); | ||
| App.Tap(toggleTabButtonId); // Removes the tab | ||
| App.Tap(toggleTabButtonId); // Re-adds the tab | ||
| App.Tap(tab2Title); | ||
| App.WaitForElement("label"); | ||
| } | ||
| } | ||
| } | ||
| } |
29 changes: 29 additions & 0 deletions
29
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue23732.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,29 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues | ||
| { | ||
| public class Issue23732: _IssuesUITest | ||
| { | ||
| public Issue23732(TestDevice testDevice) : base(testDevice) | ||
| { | ||
| } | ||
| public override string Issue => "TabBar content not displayed properly"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.TabbedPage)] | ||
| public void TabbedPageTabContentUpdated() | ||
jfversluis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| #if ANDROID | ||
| string pageTitle = "PAGE 4"; | ||
| #else | ||
| string pageTitle = "Page 4"; | ||
| #endif | ||
| App.WaitForElement(pageTitle); | ||
| App.Tap(pageTitle); | ||
| var label = App.WaitForElement("label"); | ||
| Assert.That(label.GetText(), Is.EqualTo("page4")); | ||
| } | ||
| } | ||
| } | ||
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.
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.
Why was this removed, is something leaking?
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.
@mattleibow As mentioned earlier, this test fails with a timeout exception when using DisconnectHandler with the fix. Since the latest code automatically calls the previous page's DisconnectHandler during navigation, I have removed this code.