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
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ void UpdateIgnoreContainerAreas()
child.IgnoresContainerArea = child is NavigationPage;
}

void UpdateOffscreenPageLimit()
internal void UpdateOffscreenPageLimit()
{
_viewPager.OffscreenPageLimit = Element.OnThisPlatform().OffscreenPageLimit();
}
Expand Down
5 changes: 5 additions & 0 deletions src/Controls/src/Core/TabbedPage/TabbedPage.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,10 @@ public static void MapIsSwipePagingEnabled(ITabbedViewHandler handler, TabbedPag
{
view._tabbedPageManager?.UpdateSwipePaging();
}

internal static void MapOffscreenPageLimit(ITabbedViewHandler handler, TabbedPage view)
{
view._tabbedPageManager?.UpdateOffscreenPageLimit();
}
}
}
1 change: 1 addition & 0 deletions src/Controls/src/Core/TabbedPage/TabbedPage.Mapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public partial class TabbedPage
TabbedViewHandler.Mapper.ReplaceMapping<TabbedPage, ITabbedViewHandler>(nameof(CurrentPage), MapCurrentPage);
#if ANDROID
TabbedViewHandler.Mapper.ReplaceMapping<TabbedPage, ITabbedViewHandler>(PlatformConfiguration.AndroidSpecific.TabbedPage.IsSwipePagingEnabledProperty.PropertyName, MapIsSwipePagingEnabled);
TabbedViewHandler.Mapper.ReplaceMapping<TabbedPage, ITabbedViewHandler>(PlatformConfiguration.AndroidSpecific.TabbedPage.OffscreenPageLimitProperty.PropertyName, MapOffscreenPageLimit);
#endif

#if WINDOWS || ANDROID || TIZEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ await CreateHandlerAndAddToWindow<WindowHandlerStub>(new Window(tabbedPage), asy
var nextPage = tabbedPage.Children[pageIndex];
tabbedPage.CurrentPage = nextPage;
await OnNavigatedToAsync(nextPage);
previousPage.Handler.DisconnectHandler();
Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Contributor Author

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.

}
});
}
Expand Down
30 changes: 30 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/23732Page.xaml
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 src/Controls/tests/TestCases.HostApp/Issues/23732Page.xaml.cs
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
};
}
}
}
65 changes: 65 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue21640.cs
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"
}
}
}
};
}
}
}
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");
}
}
}
}
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()
{
#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"));
}
}
}
Loading