Skip to content

Commit 86ccc08

Browse files
kubafloPureWeen
authored andcommitted
[iOS] Skip current page update for 'More' tab selection (#31385)
Prevents UpdateCurrentPage from being called when the 'More' navigation controller is selected in TabbedRenderer on iOS, handling the special case where the user navigates to additional tabs. Added a UITest
1 parent 22e6058 commit 86ccc08

File tree

4 files changed

+89
-0
lines changed

4 files changed

+89
-0
lines changed

src/Controls/src/Core/Compatibility/Handlers/TabbedPage/iOS/TabbedRenderer.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ public override UIViewController SelectedViewController
5151
set
5252
{
5353
base.SelectedViewController = value;
54+
// If the selected view controller is the "More" navigation controller, do not update the current page
55+
// because it is a special case where the user is navigating to a different set of tabs
56+
if (value == MoreNavigationController)
57+
return;
58+
5459
UpdateCurrentPage();
5560
}
5661
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<TabbedPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:controls="clr-namespace:Maui.Controls.Sample.Issues"
5+
xmlns:cmp="clr-namespace:Microsoft.Maui.Controls.Compatibility;assembly=Microsoft.Maui.Controls"
6+
ItemsSource="{Binding ItemsSource}"
7+
x:Class="Maui.Controls.Sample.Issues.Issue31377">
8+
<TabbedPage.ItemTemplate>
9+
<DataTemplate>
10+
<ContentPage Title="{Binding Name}"
11+
IconImageSource="coffee.png">
12+
<StackLayout Padding="5, 25">
13+
<Label Text="{Binding Name}"
14+
FontAttributes="Bold"
15+
FontSize="18"
16+
HorizontalOptions="Center"/>
17+
<Image Source="{Binding ImageUrl}"
18+
HorizontalOptions="Center"
19+
WidthRequest="100"
20+
HeightRequest="100"/>
21+
</StackLayout>
22+
</ContentPage>
23+
</DataTemplate>
24+
</TabbedPage.ItemTemplate>
25+
</TabbedPage>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Collections.ObjectModel;
2+
3+
namespace Maui.Controls.Sample.Issues;
4+
5+
[Issue(IssueTracker.Github, 31377, "TabbedPage overflow 'More' button does not work", PlatformAffected.iOS)]
6+
public partial class Issue31377 : TabbedPage
7+
{
8+
public Issue31377()
9+
{
10+
InitializeComponent();
11+
BindingContext = new TabbedPageViewModel();
12+
}
13+
14+
public class TabbedPageViewModel
15+
{
16+
public ObservableCollection<TabbedPageItemSource> ItemsSource { get; } =
17+
[
18+
new TabbedPageItemSource { Name = "Tab 1", ImageUrl = "dotnet_bot.png" },
19+
new TabbedPageItemSource { Name = "Tab 2", ImageUrl = "dotnet_bot.png" },
20+
new TabbedPageItemSource { Name = "Tab 3", ImageUrl = "dotnet_bot.png" },
21+
new TabbedPageItemSource { Name = "Tab 4", ImageUrl = "dotnet_bot.png" },
22+
new TabbedPageItemSource { Name = "Tab 5", ImageUrl = "dotnet_bot.png" },
23+
new TabbedPageItemSource { Name = "Tab 6", ImageUrl = "dotnet_bot.png" },
24+
new TabbedPageItemSource { Name = "Tab 7", ImageUrl = "dotnet_bot.png" },
25+
new TabbedPageItemSource { Name = "Tab 8", ImageUrl = "dotnet_bot.png" },
26+
new TabbedPageItemSource { Name = "Tab 9", ImageUrl = "dotnet_bot.png" },
27+
new TabbedPageItemSource { Name = "Tab 10", ImageUrl = "dotnet_bot.png" }
28+
];
29+
}
30+
31+
public class TabbedPageItemSource
32+
{
33+
public string Name { get; set; }
34+
public string ImageUrl { get; set; }
35+
}
36+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#if TEST_FAILS_ON_WINDOWS && TEST_FAILS_ON_ANDROID //The more page works differently on these platforms
2+
using NUnit.Framework;
3+
using UITest.Appium;
4+
using UITest.Core;
5+
6+
namespace Microsoft.Maui.TestCases.Tests.Issues;
7+
8+
public class Issue31377 : _IssuesUITest
9+
{
10+
public Issue31377(TestDevice testDevice) : base(testDevice) { }
11+
12+
public override string Issue => "TabbedPage overflow 'More' button does not work";
13+
14+
[Test]
15+
[Category(UITestCategories.TabbedPage)]
16+
public void Issue31377TestsOverflowMoreButton()
17+
{
18+
App.WaitForElement("More");
19+
App.Tap("More");
20+
App.WaitForElement("Tab 10");
21+
}
22+
}
23+
#endif

0 commit comments

Comments
 (0)