From a4182b570f47eed850537d079008a58b3c3cae51 Mon Sep 17 00:00:00 2001 From: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com> Date: Thu, 19 Dec 2024 19:27:34 +0530 Subject: [PATCH 01/22] Fixed IsEnabled Property is not works for Tab --- .../Handlers/Shell/iOS/ShellItemRenderer.cs | 11 ++ .../Shell/ShellItemHandler.Windows.cs | 49 +++++++- .../Windows/TabbedPage/TabbedPageStyle.xaml | 1 + .../TestCases.HostApp/Issues/Issue5161.cs | 109 ++++++++++++++++++ .../Tests/Issues/Issue5161.cs | 23 ++++ .../Windows/NavigationViewItemViewModel.cs | 13 +++ 6 files changed, 203 insertions(+), 3 deletions(-) create mode 100644 src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs create mode 100644 src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs diff --git a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs index 5d29846d0125..624e6b1cbddf 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs @@ -356,9 +356,20 @@ void CreateTabRenderers() // Make sure we are at the right item GoTo(ShellItem.CurrentItem); + UpdateCellsEnabled(); UpdateMoreCellsEnabled(); } + private void UpdateCellsEnabled() + { + for (int i = 1; i < TabBar.Items.Length; i++) + { + var tab = TabBar.Items[i]; + var itemRenderer = RendererForViewController(ViewControllers[i]); + tab.Enabled = itemRenderer.ShellSection.IsEnabled; + } + } + void UpdateMoreCellsEnabled() { var moreNavigationCells = GetMoreNavigationCells(); diff --git a/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs b/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs index 3850a5f3aa7b..f0d7a4ac43b7 100644 --- a/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs +++ b/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs @@ -115,11 +115,17 @@ protected override void DisconnectHandler(FrameworkElement platformView) } if (_shellItem is IShellItemController shellItemController) + { shellItemController.ItemsCollectionChanged -= OnItemsChanged; - if (VirtualView.Parent is Shell shell) - { - shell.Navigated -= OnShellNavigated; + if (VirtualView.Parent is Shell shell) + { + shell.Navigated -= OnShellNavigated; + foreach (var item in shellItemController.GetItems()) + { + item.PropertyChanged -= OnShellItemPropertyChanged; + } + } } } @@ -203,6 +209,7 @@ internal void MapMenuItems() foreach (var item in shellItemController.GetItems()) { + item.PropertyChanged += OnShellItemPropertyChanged; if (Routing.IsImplicit(item)) items.Add(item.CurrentItem); else @@ -254,6 +261,7 @@ internal void MapMenuItems() void SetValues(BaseShellItem bsi, NavigationViewItemViewModel vm) { vm.Content = bsi.Title; + vm.IsEnabled = bsi.IsEnabled; var iconSource = bsi.Icon?.ToIconSource(MauiContext!); if (iconSource != null) @@ -409,6 +417,41 @@ void OnSearchBoxQuerySubmitted(Microsoft.UI.Xaml.Controls.AutoSuggestBox sender, } } + private void OnShellItemPropertyChanged(object? sender, PropertyChangedEventArgs e) + { + if (_mainLevelTabs == null) + return; + + if (e.PropertyName == nameof(BaseShellItem.IsEnabled)) + { + foreach (var items in _mainLevelTabs) + { + if (items.Data == sender) + { + if (sender is BaseShellItem shellItem) + { + items.IsEnabled = shellItem.IsEnabled; + } + break; + } + } + } + else if (e.PropertyName == nameof(BaseShellItem.Title)) + { + foreach (var items in _mainLevelTabs) + { + if (items.Data == sender) + { + if (sender is BaseShellItem shellItem) + { + items.Content = shellItem.Title; + } + break; + } + } + } + } + void OnCurrentSearchHandlerPropertyChanged(object? sender, PropertyChangedEventArgs e) { if (_currentSearchHandler is null) diff --git a/src/Controls/src/Core/Platform/Windows/TabbedPage/TabbedPageStyle.xaml b/src/Controls/src/Core/Platform/Windows/TabbedPage/TabbedPageStyle.xaml index a954d9dbfed7..602a7ed0ee00 100644 --- a/src/Controls/src/Core/Platform/Windows/TabbedPage/TabbedPageStyle.xaml +++ b/src/Controls/src/Core/Platform/Windows/TabbedPage/TabbedPageStyle.xaml @@ -7,6 +7,7 @@ x:Name="navViewItem" Content="{Binding Content}" Background="{Binding Background}" + IsEnabled="{Binding IsEnabled}" IsSelected="{Binding IsSelected, Mode=TwoWay}" MenuItemsSource="{Binding MenuItemsSource}" Icon="{Binding Icon}" diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs new file mode 100644 index 000000000000..a6efb2fb351d --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs @@ -0,0 +1,109 @@ +using System; +using Microsoft.Maui.Controls; + +namespace CControls.TestCases.HostApp.Issues; +[Issue(IssueTracker.Github, 5161, "ShellContent IsEnabledProperty does not work", PlatformAffected.iOS)] +public class Issue5161 : Shell +{ + public Issue5161() + { + var mainPageTab = new Tab + { + Title = "First Page", + IsEnabled = true, + }; + mainPageTab.Items.Add(new ShellContent + { + ContentTemplate = new DataTemplate(() => new Issue5161_MainPage()) + }); + + var secondPageTab = new Tab + { + Title = "Second Page", + IsEnabled = false, + AutomationId = "SecondPage" + }; + secondPageTab.Items.Add(new ShellContent + { + ContentTemplate = new DataTemplate(() => new SecondPage()) + }); + var thirdTab = new Tab + { + Title = "Third Page", + IsEnabled = true, + AutomationId = "ThirdPage" + }; + thirdTab.Items.Add(new ShellContent + { + ContentTemplate = new DataTemplate(() => new ThirdPage()) + }); + var tabBar = new TabBar(); + tabBar.Items.Add(mainPageTab); + tabBar.Items.Add(secondPageTab); + tabBar.Items.Add(thirdTab); + Items.Add(tabBar); + } + + public class Issue5161_MainPage : ContentPage + { + public Issue5161_MainPage() + { + Content = new StackLayout + { + VerticalOptions = LayoutOptions.CenterAndExpand, + HorizontalOptions = LayoutOptions.CenterAndExpand, + Children = + { + new Label + { + Text = "This is First Page", + VerticalOptions = LayoutOptions.CenterAndExpand, + HorizontalOptions = LayoutOptions.CenterAndExpand + } + } + }; + } + } + + public class SecondPage : ContentPage + { + public SecondPage() + { + Content = new StackLayout + { + VerticalOptions = LayoutOptions.CenterAndExpand, + HorizontalOptions = LayoutOptions.CenterAndExpand, + Children = + { + new Label + { + Text = "This is Second Page", + VerticalOptions = LayoutOptions.CenterAndExpand, + HorizontalOptions = LayoutOptions.CenterAndExpand + } + } + }; + } + } + public class ThirdPage : ContentPage + { + public ThirdPage() + { + Content = new StackLayout + { + VerticalOptions = LayoutOptions.CenterAndExpand, + HorizontalOptions = LayoutOptions.CenterAndExpand, + Children = + { + new Label + { + Text = "This is Third Page", + VerticalOptions = LayoutOptions.CenterAndExpand, + HorizontalOptions = LayoutOptions.CenterAndExpand + } + } + }; + } + } +} + diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs new file mode 100644 index 000000000000..0eb1965f645b --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs @@ -0,0 +1,23 @@ +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues; +public class Issue5161:_IssuesUITest +{ +public Issue5161(TestDevice testDevice) : base(testDevice) + { + } + + public override string Issue => "ShellContent IsEnabledProperty does not work"; + + [Test] + [Category(UITestCategories.Shell)] + public void CheckIsEnabled() + { + App.WaitForElement("ThirdPage"); + App.Tap("ThirdPage"); + App.Tap("SecondPage"); + VerifyScreenshot(); + } +} diff --git a/src/Core/src/Platform/Windows/NavigationViewItemViewModel.cs b/src/Core/src/Platform/Windows/NavigationViewItemViewModel.cs index aa0b0d9ba5c6..c1f4d3b045cc 100644 --- a/src/Core/src/Platform/Windows/NavigationViewItemViewModel.cs +++ b/src/Core/src/Platform/Windows/NavigationViewItemViewModel.cs @@ -82,6 +82,7 @@ internal class NavigationViewItemViewModel : INotifyPropertyChanged object? _content; bool _isSelected; + bool _isEnabled; WBrush? _selectedBackground; WBrush? _unselectedBackground; WBrush? _selectedForeground; @@ -232,6 +233,18 @@ public bool IsSelected } } + public bool IsEnabled + { + get => _isEnabled; + set + { + if (_isEnabled != value) + { + _isEnabled = value; + OnPropertyChanged(nameof(IsEnabled)); + } + } + } void OnPropertyChanged(string args) => OnPropertyChanged(new PropertyChangedEventArgs(args)); From 05bc470ec4c5eedd2871f0fdc0ec303b29acab59 Mon Sep 17 00:00:00 2001 From: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com> Date: Thu, 19 Dec 2024 23:00:14 +0530 Subject: [PATCH 02/22] Modified Test case and Optimized code for runtime changes for WinUI --- .../Shell/ShellItemHandler.Windows.cs | 34 ++++++------------- .../TestCases.HostApp/Issues/Issue5161.cs | 6 ++-- .../Tests/Issues/Issue5161.cs | 2 +- 3 files changed, 14 insertions(+), 28 deletions(-) diff --git a/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs b/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs index f0d7a4ac43b7..db3f3f6d6067 100644 --- a/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs +++ b/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs @@ -419,36 +419,22 @@ void OnSearchBoxQuerySubmitted(Microsoft.UI.Xaml.Controls.AutoSuggestBox sender, private void OnShellItemPropertyChanged(object? sender, PropertyChangedEventArgs e) { - if (_mainLevelTabs == null) + if (_mainLevelTabs == null || sender is not BaseShellItem shellItem) return; - - if (e.PropertyName == nameof(BaseShellItem.IsEnabled)) + for (int i = 0; i < _mainLevelTabs.Count; i++) { - foreach (var items in _mainLevelTabs) + if (_mainLevelTabs[i].Data != sender) + continue; + switch (e.PropertyName) { - if (items.Data == sender) - { - if (sender is BaseShellItem shellItem) - { - items.IsEnabled = shellItem.IsEnabled; - } + case nameof(BaseShellItem.IsEnabled): + _mainLevelTabs[i].IsEnabled = shellItem.IsEnabled; break; - } - } - } - else if (e.PropertyName == nameof(BaseShellItem.Title)) - { - foreach (var items in _mainLevelTabs) - { - if (items.Data == sender) - { - if (sender is BaseShellItem shellItem) - { - items.Content = shellItem.Title; - } + case nameof(BaseShellItem.Title): + _mainLevelTabs[i].Content = shellItem.Title; break; - } } + return; } } diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs index a6efb2fb351d..53b247be6e12 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs @@ -9,7 +9,7 @@ public Issue5161() { var mainPageTab = new Tab { - Title = "First Page", + Title = "FirstPage", IsEnabled = true, }; mainPageTab.Items.Add(new ShellContent @@ -19,7 +19,7 @@ public Issue5161() var secondPageTab = new Tab { - Title = "Second Page", + Title = "SecondPage", IsEnabled = false, AutomationId = "SecondPage" }; @@ -29,7 +29,7 @@ public Issue5161() }); var thirdTab = new Tab { - Title = "Third Page", + Title = "ThirdPage", IsEnabled = true, AutomationId = "ThirdPage" }; diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs index 0eb1965f645b..cd0af755cec8 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs @@ -18,6 +18,6 @@ public void CheckIsEnabled() App.WaitForElement("ThirdPage"); App.Tap("ThirdPage"); App.Tap("SecondPage"); - VerifyScreenshot(); + App.WaitForElement("This is Third Page"); } } From 33e4142d08e7047d3464cc1327e6ebdbd5a689d8 Mon Sep 17 00:00:00 2001 From: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com> Date: Fri, 20 Dec 2024 12:09:10 +0530 Subject: [PATCH 03/22] Removed AndExpand in test samples --- .../TestCases.HostApp/Issues/Issue5161.cs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs index 53b247be6e12..98c153f9e5e5 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs @@ -50,15 +50,13 @@ public Issue5161_MainPage() { Content = new StackLayout { - VerticalOptions = LayoutOptions.CenterAndExpand, - HorizontalOptions = LayoutOptions.CenterAndExpand, + VerticalOptions = LayoutOptions.Center, + HorizontalOptions = LayoutOptions.Center, Children = { new Label { Text = "This is First Page", - VerticalOptions = LayoutOptions.CenterAndExpand, - HorizontalOptions = LayoutOptions.CenterAndExpand } } }; @@ -71,15 +69,13 @@ public SecondPage() { Content = new StackLayout { - VerticalOptions = LayoutOptions.CenterAndExpand, - HorizontalOptions = LayoutOptions.CenterAndExpand, + VerticalOptions = LayoutOptions.Center, + HorizontalOptions = LayoutOptions.Center, Children = { new Label { Text = "This is Second Page", - VerticalOptions = LayoutOptions.CenterAndExpand, - HorizontalOptions = LayoutOptions.CenterAndExpand } } }; @@ -91,15 +87,13 @@ public ThirdPage() { Content = new StackLayout { - VerticalOptions = LayoutOptions.CenterAndExpand, - HorizontalOptions = LayoutOptions.CenterAndExpand, + VerticalOptions = LayoutOptions.Center, + HorizontalOptions = LayoutOptions.Center, Children = { new Label { Text = "This is Third Page", - VerticalOptions = LayoutOptions.CenterAndExpand, - HorizontalOptions = LayoutOptions.CenterAndExpand } } }; From 1b08d251d6bf7cc577d46722c9a228da9e72babf Mon Sep 17 00:00:00 2001 From: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com> Date: Fri, 20 Dec 2024 16:14:11 +0530 Subject: [PATCH 04/22] Modified test cases --- .vscode/launch.json | 14 +++++++ .../TestCases.HostApp/Issues/Issue5161.cs | 39 ++++++++++++++++--- .../Tests/Issues/Issue5161.cs | 5 ++- 3 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000000..a81bd58ee982 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,14 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": ".NET MAUI", + "type": "maui", + "request": "launch", + "preLaunchTask": "maui: Build" + } + ] +} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs index 98c153f9e5e5..b38168d9b281 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs @@ -75,7 +75,8 @@ public SecondPage() { new Label { - Text = "This is Second Page", + Text="This is second Page", + AutomationId="SecondPageLabel" } } }; @@ -85,18 +86,46 @@ public class ThirdPage : ContentPage { public ThirdPage() { + var label = new Label + { + Text = "This is Third Page", + HorizontalOptions = LayoutOptions.Center, + VerticalOptions = LayoutOptions.Center + }; + + var button = new Button + { + Text = "Enable SecondTab", + HorizontalOptions = LayoutOptions.Center, + VerticalOptions = LayoutOptions.Center, + }; + button.AutomationId="Button"; + button.Clicked += OnButtonClicked; Content = new StackLayout { VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, Children = { - new Label - { - Text = "This is Third Page", - } + label, + button } }; + + } + private void OnButtonClicked(object sender, EventArgs e) + { + if (Application.Current?.Windows.Count > 0 && + Application.Current.Windows[0].Page is Shell shell) + { + var secondTab = shell.CurrentItem?.Items[1]; + if (secondTab is not null) + secondTab.IsEnabled = true; + } + else + { + System.Diagnostics.Debug.WriteLine("Shell not found!"); + } } } } diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs index cd0af755cec8..08adc06758e8 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs @@ -18,6 +18,9 @@ public void CheckIsEnabled() App.WaitForElement("ThirdPage"); App.Tap("ThirdPage"); App.Tap("SecondPage"); - App.WaitForElement("This is Third Page"); + App.WaitForNoElement("SecondPageLabel"); + App.Tap("Button"); + App.Tap("SecondPage"); + App.WaitForElement("SecondPageLabel"); } } From 325c21ecf257528f2aca73117ebc41d7e36c44d0 Mon Sep 17 00:00:00 2001 From: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com> Date: Fri, 20 Dec 2024 16:19:01 +0530 Subject: [PATCH 05/22] Revert "Modified test cases" This reverts commit 369097da8bf98ddb1d1f1e63127cc5b2adb401ee. --- .vscode/launch.json | 14 ------- .../TestCases.HostApp/Issues/Issue5161.cs | 39 +++---------------- .../Tests/Issues/Issue5161.cs | 5 +-- 3 files changed, 6 insertions(+), 52 deletions(-) delete mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index a81bd58ee982..000000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": ".NET MAUI", - "type": "maui", - "request": "launch", - "preLaunchTask": "maui: Build" - } - ] -} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs index b38168d9b281..98c153f9e5e5 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs @@ -75,8 +75,7 @@ public SecondPage() { new Label { - Text="This is second Page", - AutomationId="SecondPageLabel" + Text = "This is Second Page", } } }; @@ -86,46 +85,18 @@ public class ThirdPage : ContentPage { public ThirdPage() { - var label = new Label - { - Text = "This is Third Page", - HorizontalOptions = LayoutOptions.Center, - VerticalOptions = LayoutOptions.Center - }; - - var button = new Button - { - Text = "Enable SecondTab", - HorizontalOptions = LayoutOptions.Center, - VerticalOptions = LayoutOptions.Center, - }; - button.AutomationId="Button"; - button.Clicked += OnButtonClicked; Content = new StackLayout { VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, Children = { - label, - button + new Label + { + Text = "This is Third Page", + } } }; - - } - private void OnButtonClicked(object sender, EventArgs e) - { - if (Application.Current?.Windows.Count > 0 && - Application.Current.Windows[0].Page is Shell shell) - { - var secondTab = shell.CurrentItem?.Items[1]; - if (secondTab is not null) - secondTab.IsEnabled = true; - } - else - { - System.Diagnostics.Debug.WriteLine("Shell not found!"); - } } } } diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs index 08adc06758e8..cd0af755cec8 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs @@ -18,9 +18,6 @@ public void CheckIsEnabled() App.WaitForElement("ThirdPage"); App.Tap("ThirdPage"); App.Tap("SecondPage"); - App.WaitForNoElement("SecondPageLabel"); - App.Tap("Button"); - App.Tap("SecondPage"); - App.WaitForElement("SecondPageLabel"); + App.WaitForElement("This is Third Page"); } } From 7d82314530370f0188938935ead2c9841fcc0c3b Mon Sep 17 00:00:00 2001 From: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com> Date: Fri, 20 Dec 2024 16:23:49 +0530 Subject: [PATCH 06/22] Modified test case to apply runtime changes --- .../TestCases.HostApp/Issues/Issue5161.cs | 39 ++++++++++++++++--- .../Tests/Issues/Issue5161.cs | 5 ++- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs index 98c153f9e5e5..d380d36b507c 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs @@ -75,7 +75,8 @@ public SecondPage() { new Label { - Text = "This is Second Page", + Text="This is second Page", + AutomationId="SecondPageLabel" } } }; @@ -85,18 +86,46 @@ public class ThirdPage : ContentPage { public ThirdPage() { + var label = new Label + { + Text = "This is Third Page", + HorizontalOptions = LayoutOptions.Center, + VerticalOptions = LayoutOptions.Center + }; + + var button = new Button + { + Text = "Enable SecondTab", + HorizontalOptions = LayoutOptions.Center, + VerticalOptions = LayoutOptions.Center, + AutomationId = "Button" + }; + button.Clicked += OnButtonClicked; Content = new StackLayout { VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, Children = { - new Label - { - Text = "This is Third Page", - } + label, + button } }; + + } + private void OnButtonClicked(object sender, EventArgs e) + { + if (Application.Current?.Windows.Count > 0 && + Application.Current.Windows[0].Page is Shell shell) + { + var secondTab = shell.CurrentItem?.Items[1]; + if (secondTab is not null) + secondTab.IsEnabled = true; + } + else + { + System.Diagnostics.Debug.WriteLine("Shell not found!"); + } } } } diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs index cd0af755cec8..08adc06758e8 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs @@ -18,6 +18,9 @@ public void CheckIsEnabled() App.WaitForElement("ThirdPage"); App.Tap("ThirdPage"); App.Tap("SecondPage"); - App.WaitForElement("This is Third Page"); + App.WaitForNoElement("SecondPageLabel"); + App.Tap("Button"); + App.Tap("SecondPage"); + App.WaitForElement("SecondPageLabel"); } } From 70454e623fbec93ee8a01d34de118698bb57f654 Mon Sep 17 00:00:00 2001 From: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com> Date: Fri, 20 Dec 2024 17:03:32 +0530 Subject: [PATCH 07/22] Changed test case naming --- .../tests/TestCases.HostApp/Issues/Issue5161.cs | 9 +++++---- .../TestCases.Shared.Tests/Tests/Issues/Issue5161.cs | 11 ++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs index d380d36b507c..019a294de44d 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs @@ -21,7 +21,7 @@ public Issue5161() { Title = "SecondPage", IsEnabled = false, - AutomationId = "SecondPage" + AutomationId = "SecondTab" }; secondPageTab.Items.Add(new ShellContent { @@ -31,7 +31,7 @@ public Issue5161() { Title = "ThirdPage", IsEnabled = true, - AutomationId = "ThirdPage" + AutomationId = "ThirdTab" }; thirdTab.Items.Add(new ShellContent { @@ -90,7 +90,8 @@ public ThirdPage() { Text = "This is Third Page", HorizontalOptions = LayoutOptions.Center, - VerticalOptions = LayoutOptions.Center + VerticalOptions = LayoutOptions.Center, + AutomationId="ThirdPageLabel" }; var button = new Button @@ -98,7 +99,7 @@ public ThirdPage() Text = "Enable SecondTab", HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, - AutomationId = "Button" + AutomationId = "EnableSecondTab" }; button.Clicked += OnButtonClicked; Content = new StackLayout diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs index 08adc06758e8..b5fb91312fa3 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs @@ -15,12 +15,13 @@ public Issue5161(TestDevice testDevice) : base(testDevice) [Category(UITestCategories.Shell)] public void CheckIsEnabled() { - App.WaitForElement("ThirdPage"); - App.Tap("ThirdPage"); - App.Tap("SecondPage"); + App.WaitForElement("ThirdTab"); + App.Tap("ThirdTab"); + App.WaitForElement("ThirdPageLabel"); + App.Tap("SecondTab"); App.WaitForNoElement("SecondPageLabel"); - App.Tap("Button"); - App.Tap("SecondPage"); + App.Tap("EnableSecondTab"); + App.Tap("SecondTab"); App.WaitForElement("SecondPageLabel"); } } From f51b2af882c2cf1d7f1909bdfe27368890c4c5c2 Mon Sep 17 00:00:00 2001 From: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com> Date: Tue, 24 Dec 2024 14:32:41 +0530 Subject: [PATCH 08/22] Fixed CI failure in Android and WinUI --- src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs index 019a294de44d..9ca2ccfe06d0 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs @@ -19,7 +19,7 @@ public Issue5161() var secondPageTab = new Tab { - Title = "SecondPage", + Title = "SecondTab", IsEnabled = false, AutomationId = "SecondTab" }; @@ -29,7 +29,7 @@ public Issue5161() }); var thirdTab = new Tab { - Title = "ThirdPage", + Title = "ThirdTab", IsEnabled = true, AutomationId = "ThirdTab" }; From 8db864dfb03823afa2c0399736b079ce9e28de77 Mon Sep 17 00:00:00 2001 From: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com> Date: Thu, 2 Jan 2025 18:39:33 +0530 Subject: [PATCH 09/22] Updated namespace --- src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs index 9ca2ccfe06d0..971da0e83e02 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs @@ -1,7 +1,7 @@ using System; using Microsoft.Maui.Controls; -namespace CControls.TestCases.HostApp.Issues; +namespace Maui.Controls.Sample.Issues; [Issue(IssueTracker.Github, 5161, "ShellContent IsEnabledProperty does not work", PlatformAffected.iOS)] public class Issue5161 : Shell { From 86ef6262951fa252ee127146e4359edbc3d526c7 Mon Sep 17 00:00:00 2001 From: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com> Date: Fri, 3 Jan 2025 11:57:55 +0530 Subject: [PATCH 10/22] Updated indentation in testcase sample --- .../TestCases.HostApp/Issues/Issue5161.cs | 5 +-- .../Tests/Issues/Issue5161.cs | 38 +++++++++---------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs index 971da0e83e02..77625568fbeb 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs @@ -91,7 +91,7 @@ public ThirdPage() Text = "This is Third Page", HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, - AutomationId="ThirdPageLabel" + AutomationId = "ThirdPageLabel" }; var button = new Button @@ -129,5 +129,4 @@ private void OnButtonClicked(object sender, EventArgs e) } } } -} - +} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs index b5fb91312fa3..1e817bded70c 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs @@ -3,25 +3,25 @@ using UITest.Core; namespace Microsoft.Maui.TestCases.Tests.Issues; -public class Issue5161:_IssuesUITest +public class Issue5161 : _IssuesUITest { -public Issue5161(TestDevice testDevice) : base(testDevice) - { - } + public Issue5161(TestDevice testDevice) : base(testDevice) + { + } - public override string Issue => "ShellContent IsEnabledProperty does not work"; + public override string Issue => "ShellContent IsEnabledProperty does not work"; - [Test] - [Category(UITestCategories.Shell)] - public void CheckIsEnabled() - { - App.WaitForElement("ThirdTab"); - App.Tap("ThirdTab"); - App.WaitForElement("ThirdPageLabel"); - App.Tap("SecondTab"); - App.WaitForNoElement("SecondPageLabel"); - App.Tap("EnableSecondTab"); - App.Tap("SecondTab"); - App.WaitForElement("SecondPageLabel"); - } -} + [Test] + [Category(UITestCategories.Shell)] + public void CheckIsEnabled() + { + App.WaitForElement("ThirdTab"); + App.Tap("ThirdTab"); + App.WaitForElement("ThirdPageLabel"); + App.Tap("SecondTab"); + App.WaitForNoElement("SecondPageLabel"); + App.Tap("EnableSecondTab"); + App.Tap("SecondTab"); + App.WaitForElement("SecondPageLabel"); + } +} \ No newline at end of file From 6a99f63f3caf268c5f9113d1765b988f4c601af7 Mon Sep 17 00:00:00 2001 From: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com> Date: Fri, 10 Jan 2025 15:51:49 +0530 Subject: [PATCH 11/22] Updated the code as loop starts from 0 --- .../Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs index 624e6b1cbddf..2da123002a0d 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs @@ -362,7 +362,7 @@ void CreateTabRenderers() private void UpdateCellsEnabled() { - for (int i = 1; i < TabBar.Items.Length; i++) + for (int i = 0; i < TabBar.Items.Length; i++) { var tab = TabBar.Items[i]; var itemRenderer = RendererForViewController(ViewControllers[i]); From b8de19e318f8d76d8e0e10e183e151abbd239d8e Mon Sep 17 00:00:00 2001 From: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com> Date: Thu, 19 Dec 2024 19:27:34 +0530 Subject: [PATCH 12/22] Fixed IsEnabled Property is not works for Tab --- .../Handlers/Shell/iOS/ShellItemRenderer.cs | 2 +- .../Shell/ShellItemHandler.Windows.cs | 34 +++++++++++++------ .../TestCases.HostApp/Issues/Issue5161.cs | 3 +- .../Tests/Issues/Issue5161.cs | 3 +- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs index 2da123002a0d..624e6b1cbddf 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs @@ -362,7 +362,7 @@ void CreateTabRenderers() private void UpdateCellsEnabled() { - for (int i = 0; i < TabBar.Items.Length; i++) + for (int i = 1; i < TabBar.Items.Length; i++) { var tab = TabBar.Items[i]; var itemRenderer = RendererForViewController(ViewControllers[i]); diff --git a/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs b/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs index db3f3f6d6067..f0d7a4ac43b7 100644 --- a/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs +++ b/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs @@ -419,22 +419,36 @@ void OnSearchBoxQuerySubmitted(Microsoft.UI.Xaml.Controls.AutoSuggestBox sender, private void OnShellItemPropertyChanged(object? sender, PropertyChangedEventArgs e) { - if (_mainLevelTabs == null || sender is not BaseShellItem shellItem) + if (_mainLevelTabs == null) return; - for (int i = 0; i < _mainLevelTabs.Count; i++) + + if (e.PropertyName == nameof(BaseShellItem.IsEnabled)) { - if (_mainLevelTabs[i].Data != sender) - continue; - switch (e.PropertyName) + foreach (var items in _mainLevelTabs) { - case nameof(BaseShellItem.IsEnabled): - _mainLevelTabs[i].IsEnabled = shellItem.IsEnabled; + if (items.Data == sender) + { + if (sender is BaseShellItem shellItem) + { + items.IsEnabled = shellItem.IsEnabled; + } break; - case nameof(BaseShellItem.Title): - _mainLevelTabs[i].Content = shellItem.Title; + } + } + } + else if (e.PropertyName == nameof(BaseShellItem.Title)) + { + foreach (var items in _mainLevelTabs) + { + if (items.Data == sender) + { + if (sender is BaseShellItem shellItem) + { + items.Content = shellItem.Title; + } break; + } } - return; } } diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs index 77625568fbeb..9ca06f70c0a6 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs @@ -2,6 +2,7 @@ using Microsoft.Maui.Controls; namespace Maui.Controls.Sample.Issues; + [Issue(IssueTracker.Github, 5161, "ShellContent IsEnabledProperty does not work", PlatformAffected.iOS)] public class Issue5161 : Shell { @@ -129,4 +130,4 @@ private void OnButtonClicked(object sender, EventArgs e) } } } -} \ No newline at end of file +} diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs index 1e817bded70c..215415d54055 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue5161.cs @@ -3,6 +3,7 @@ using UITest.Core; namespace Microsoft.Maui.TestCases.Tests.Issues; + public class Issue5161 : _IssuesUITest { public Issue5161(TestDevice testDevice) : base(testDevice) @@ -24,4 +25,4 @@ public void CheckIsEnabled() App.Tap("SecondTab"); App.WaitForElement("SecondPageLabel"); } -} \ No newline at end of file +} From 45d6a49f437a941a1c9681d54be7a21b30f71a4a Mon Sep 17 00:00:00 2001 From: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com> Date: Thu, 19 Dec 2024 23:00:14 +0530 Subject: [PATCH 13/22] Modified Test case and Optimized code for runtime changes for WinUI --- .../Shell/ShellItemHandler.Windows.cs | 34 ++++++------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs b/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs index f0d7a4ac43b7..db3f3f6d6067 100644 --- a/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs +++ b/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs @@ -419,36 +419,22 @@ void OnSearchBoxQuerySubmitted(Microsoft.UI.Xaml.Controls.AutoSuggestBox sender, private void OnShellItemPropertyChanged(object? sender, PropertyChangedEventArgs e) { - if (_mainLevelTabs == null) + if (_mainLevelTabs == null || sender is not BaseShellItem shellItem) return; - - if (e.PropertyName == nameof(BaseShellItem.IsEnabled)) + for (int i = 0; i < _mainLevelTabs.Count; i++) { - foreach (var items in _mainLevelTabs) + if (_mainLevelTabs[i].Data != sender) + continue; + switch (e.PropertyName) { - if (items.Data == sender) - { - if (sender is BaseShellItem shellItem) - { - items.IsEnabled = shellItem.IsEnabled; - } + case nameof(BaseShellItem.IsEnabled): + _mainLevelTabs[i].IsEnabled = shellItem.IsEnabled; break; - } - } - } - else if (e.PropertyName == nameof(BaseShellItem.Title)) - { - foreach (var items in _mainLevelTabs) - { - if (items.Data == sender) - { - if (sender is BaseShellItem shellItem) - { - items.Content = shellItem.Title; - } + case nameof(BaseShellItem.Title): + _mainLevelTabs[i].Content = shellItem.Title; break; - } } + return; } } From 8a46930be7b5c20c886252b35a3e4602688fc05d Mon Sep 17 00:00:00 2001 From: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com> Date: Fri, 20 Dec 2024 16:14:11 +0530 Subject: [PATCH 14/22] Modified test cases --- .vscode/launch.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000000..a81bd58ee982 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,14 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": ".NET MAUI", + "type": "maui", + "request": "launch", + "preLaunchTask": "maui: Build" + } + ] +} \ No newline at end of file From 70c94c71f2e55ec11e5674f8ba8b0e034b134f20 Mon Sep 17 00:00:00 2001 From: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com> Date: Fri, 20 Dec 2024 16:19:01 +0530 Subject: [PATCH 15/22] Revert "Modified test cases" This reverts commit 369097da8bf98ddb1d1f1e63127cc5b2adb401ee. --- .vscode/launch.json | 14 -------------- .../tests/TestCases.HostApp/Issues/Issue5161.cs | 11 ++++++----- 2 files changed, 6 insertions(+), 19 deletions(-) delete mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index a81bd58ee982..000000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": ".NET MAUI", - "type": "maui", - "request": "launch", - "preLaunchTask": "maui: Build" - } - ] -} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs index 9ca06f70c0a6..39797cbddd44 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs @@ -76,8 +76,7 @@ public SecondPage() { new Label { - Text="This is second Page", - AutomationId="SecondPageLabel" + Text = "This is Second Page", } } }; @@ -109,12 +108,14 @@ public ThirdPage() HorizontalOptions = LayoutOptions.Center, Children = { - label, - button + new Label + { + Text = "This is Third Page", + } } }; - } + private void OnButtonClicked(object sender, EventArgs e) { if (Application.Current?.Windows.Count > 0 && From 3f4832864021a53db723f043261c12821b7b0996 Mon Sep 17 00:00:00 2001 From: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com> Date: Fri, 10 Jan 2025 15:51:49 +0530 Subject: [PATCH 16/22] Updated the code as loop starts from 0 --- .../Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs index 624e6b1cbddf..2da123002a0d 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs @@ -362,7 +362,7 @@ void CreateTabRenderers() private void UpdateCellsEnabled() { - for (int i = 1; i < TabBar.Items.Length; i++) + for (int i = 0; i < TabBar.Items.Length; i++) { var tab = TabBar.Items[i]; var itemRenderer = RendererForViewController(ViewControllers[i]); From 94fa4bb4a094005831cb88bb9b9fb97019506793 Mon Sep 17 00:00:00 2001 From: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com> Date: Wed, 5 Feb 2025 19:00:12 +0530 Subject: [PATCH 17/22] Removed unwanted keyword --- .../Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs | 2 +- .../src/Core/Handlers/Shell/ShellItemHandler.Windows.cs | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs index 2da123002a0d..61d2fc30c8a1 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs @@ -360,7 +360,7 @@ void CreateTabRenderers() UpdateMoreCellsEnabled(); } - private void UpdateCellsEnabled() + void UpdateCellsEnabled() { for (int i = 0; i < TabBar.Items.Length; i++) { diff --git a/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs b/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs index db3f3f6d6067..beb9637cd847 100644 --- a/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs +++ b/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs @@ -417,14 +417,20 @@ void OnSearchBoxQuerySubmitted(Microsoft.UI.Xaml.Controls.AutoSuggestBox sender, } } - private void OnShellItemPropertyChanged(object? sender, PropertyChangedEventArgs e) + void OnShellItemPropertyChanged(object? sender, PropertyChangedEventArgs e) { if (_mainLevelTabs == null || sender is not BaseShellItem shellItem) + { return; + } + for (int i = 0; i < _mainLevelTabs.Count; i++) { if (_mainLevelTabs[i].Data != sender) + { continue; + } + switch (e.PropertyName) { case nameof(BaseShellItem.IsEnabled): From b55e98d8fa8026a2b9698a42966d25824a884bed Mon Sep 17 00:00:00 2001 From: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com> Date: Mon, 14 Jul 2025 12:09:32 +0530 Subject: [PATCH 18/22] Included the removed test sample --- src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs index 39797cbddd44..d8d9ea11041e 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs @@ -108,10 +108,8 @@ public ThirdPage() HorizontalOptions = LayoutOptions.Center, Children = { - new Label - { - Text = "This is Third Page", - } + label, + button } }; } From 23ac384dbc43b7b5ae5196ee2e7d9a5541a158f9 Mon Sep 17 00:00:00 2001 From: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com> Date: Mon, 14 Jul 2025 12:17:39 +0530 Subject: [PATCH 19/22] Updated ShellItemHandler.Windows --- .../Core/Handlers/Shell/ShellItemHandler.Windows.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs b/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs index beb9637cd847..c5c8725ba264 100644 --- a/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs +++ b/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs @@ -121,11 +121,13 @@ protected override void DisconnectHandler(FrameworkElement platformView) if (VirtualView.Parent is Shell shell) { shell.Navigated -= OnShellNavigated; - foreach (var item in shellItemController.GetItems()) - { - item.PropertyChanged -= OnShellItemPropertyChanged; - } } + + foreach (var item in shellItemController.GetItems()) + { + item.PropertyChanged -= OnShellItemPropertyChanged; + } + } } From e9f188aa45d84c6d1adcf1c8d4dc31a8d2832cd9 Mon Sep 17 00:00:00 2001 From: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com> Date: Tue, 15 Jul 2025 18:24:57 +0530 Subject: [PATCH 20/22] Fixed CI failure --- .../Handlers/Shell/iOS/ShellItemRenderer.cs | 12 ++++++++---- .../tests/TestCases.HostApp/Issues/Issue5161.cs | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs index 61d2fc30c8a1..5e9ddfaf0474 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs @@ -54,6 +54,7 @@ void IAppearanceObserver.OnAppearanceChanged(ShellAppearance appearance) bool _disposed; ShellItem _shellItem; static UIColor _defaultMoreTextLabelTextColor; + const int MaxTabs = 5; internal IShellSectionRenderer CurrentRenderer { get; private set; } @@ -331,8 +332,7 @@ void CreateTabRenderers() var items = ShellItemController.GetItems(); var count = items.Count; - int maxTabs = 5; // fetch this a better way - bool willUseMore = count > maxTabs; + bool willUseMore = count > MaxTabs; UIViewController[] viewControllers = new UIViewController[count]; int i = 0; @@ -340,7 +340,7 @@ void CreateTabRenderers() { var renderer = _context.CreateShellSectionRenderer(shellContent); - renderer.IsInMoreTab = willUseMore && i >= maxTabs - 1; + renderer.IsInMoreTab = willUseMore && i >= MaxTabs - 1; renderer.ShellSection = shellContent; AddRenderer(renderer); @@ -362,7 +362,11 @@ void CreateTabRenderers() void UpdateCellsEnabled() { - for (int i = 0; i < TabBar.Items.Length; i++) + // Skip disabling the "More" tab to ensure overflow tabs remain accessible. + bool willUseMore = ViewControllers.Length > MaxTabs; + var tabCount = TabBar.Items.Length - (willUseMore ? 1 : 0); + + for (int i = 0; i < tabCount; i++) { var tab = TabBar.Items[i]; var itemRenderer = RendererForViewController(ViewControllers[i]); diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs index d8d9ea11041e..a253e377a1bc 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue5161.cs @@ -77,6 +77,7 @@ public SecondPage() new Label { Text = "This is Second Page", + AutomationId = "SecondPageLabel" } } }; From 131219bc88626895947099b3606b0abcd009ea01 Mon Sep 17 00:00:00 2001 From: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com> Date: Thu, 17 Jul 2025 12:41:23 +0530 Subject: [PATCH 21/22] Fixed CI failure for windows platform --- src/Controls/src/Core/TabbedPage/TabbedPage.Windows.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Controls/src/Core/TabbedPage/TabbedPage.Windows.cs b/src/Controls/src/Core/TabbedPage/TabbedPage.Windows.cs index a079cbeea77a..49ee36888e2d 100644 --- a/src/Controls/src/Core/TabbedPage/TabbedPage.Windows.cs +++ b/src/Controls/src/Core/TabbedPage/TabbedPage.Windows.cs @@ -379,6 +379,7 @@ internal static void MapItemsSource(ITabbedViewHandler handler, TabbedPage view) vm.SelectedForeground = view.SelectedTabColor?.AsPaint()?.ToPlatform(); vm.UnselectedForeground = view.UnselectedTabColor?.AsPaint()?.ToPlatform(); vm.IsSelected = page == view.CurrentPage; + vm.IsEnabled = page.IsEnabled; }); handler.UpdateValue(nameof(TabbedPage.CurrentPage)); From 8f70cceca396b1165e6cd37d3e6237c7955c4142 Mon Sep 17 00:00:00 2001 From: Dhivya-SF4094 <127717131+Dhivya-SF4094@users.noreply.github.com> Date: Mon, 23 Feb 2026 10:34:40 +0530 Subject: [PATCH 22/22] Reverted iOS fix; already addressed in PR #33369. --- .../Handlers/Shell/iOS/ShellItemRenderer.cs | 21 +++---------------- 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs index 5e9ddfaf0474..5d29846d0125 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs @@ -54,7 +54,6 @@ void IAppearanceObserver.OnAppearanceChanged(ShellAppearance appearance) bool _disposed; ShellItem _shellItem; static UIColor _defaultMoreTextLabelTextColor; - const int MaxTabs = 5; internal IShellSectionRenderer CurrentRenderer { get; private set; } @@ -332,7 +331,8 @@ void CreateTabRenderers() var items = ShellItemController.GetItems(); var count = items.Count; - bool willUseMore = count > MaxTabs; + int maxTabs = 5; // fetch this a better way + bool willUseMore = count > maxTabs; UIViewController[] viewControllers = new UIViewController[count]; int i = 0; @@ -340,7 +340,7 @@ void CreateTabRenderers() { var renderer = _context.CreateShellSectionRenderer(shellContent); - renderer.IsInMoreTab = willUseMore && i >= MaxTabs - 1; + renderer.IsInMoreTab = willUseMore && i >= maxTabs - 1; renderer.ShellSection = shellContent; AddRenderer(renderer); @@ -356,24 +356,9 @@ void CreateTabRenderers() // Make sure we are at the right item GoTo(ShellItem.CurrentItem); - UpdateCellsEnabled(); UpdateMoreCellsEnabled(); } - void UpdateCellsEnabled() - { - // Skip disabling the "More" tab to ensure overflow tabs remain accessible. - bool willUseMore = ViewControllers.Length > MaxTabs; - var tabCount = TabBar.Items.Length - (willUseMore ? 1 : 0); - - for (int i = 0; i < tabCount; i++) - { - var tab = TabBar.Items[i]; - var itemRenderer = RendererForViewController(ViewControllers[i]); - tab.Enabled = itemRenderer.ShellSection.IsEnabled; - } - } - void UpdateMoreCellsEnabled() { var moreNavigationCells = GetMoreNavigationCells();