From c71a758e4635ea7be1b2dd2e7d33f78386fc60e5 Mon Sep 17 00:00:00 2001 From: Vignesh-SF3580 Date: Fri, 8 Nov 2024 19:23:38 +0530 Subject: [PATCH 1/3] Fixed - 25599 : OnNavigating wrong target when tapping the same tab --- .../Handlers/Shell/iOS/ShellItemRenderer.cs | 4 ++-- .../Handlers/Shell/ShellItemHandler.Windows.cs | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 3 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 ff509574fd5f..e780d2c79810 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs @@ -113,9 +113,9 @@ public override void ViewDidLoad() ShouldSelectViewController = (tabController, viewController) => { - bool accept = true; + bool accept = false; var r = RendererForViewController(viewController); - if (r != null) + if (r is not null && r != SelectedViewController) accept = ((IShellItemController)ShellItem).ProposeSection(r.ShellSection, false); return accept; diff --git a/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs b/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs index b60e49ca4126..a1a88e22a1f3 100644 --- a/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs +++ b/src/Controls/src/Core/Handlers/Shell/ShellItemHandler.Windows.cs @@ -141,8 +141,22 @@ private void OnNavigationTabChanged(NavigationView sender, NavigationViewSelecti var selectedItem = (NavigationViewItemViewModel)args.SelectedItem; - if (selectedItem.Data is ShellSection shellSection) + if (selectedItem.Data is ShellSection shellSection && VirtualView.Parent is Shell shell) { + NavigationViewItemViewModel? currentItem = null; + foreach (var item in _mainLevelTabs) + { + if (shell.CurrentItem?.CurrentItem is not null && item.Data == shell.CurrentItem.CurrentItem) + { + currentItem = item; + break; + } + } + if (PlatformView is NavigationView navView && navView?.SelectedItem is not null && navView.SelectedItem != currentItem) + { + ((IShellItemController)shell.CurrentItem!).ProposeSection(shellSection); + } + ((Shell)VirtualView.Parent).CurrentItem = shellSection; } else if (selectedItem.Data is ShellContent shellContent) From 65d2b82ee3646822164e97eb0d047891af6b6d2b Mon Sep 17 00:00:00 2001 From: Vignesh-SF3580 Date: Thu, 14 Nov 2024 19:09:01 +0530 Subject: [PATCH 2/3] Added testcasees. --- .../TestCases.HostApp/Issues/Issue25599.xaml | 37 +++++++++++++++++++ .../Issues/Issue25599.xaml.cs | 35 ++++++++++++++++++ .../Tests/Issues/Issue25599.cs | 27 ++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 src/Controls/tests/TestCases.HostApp/Issues/Issue25599.xaml create mode 100644 src/Controls/tests/TestCases.HostApp/Issues/Issue25599.xaml.cs create mode 100644 src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue25599.cs diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue25599.xaml b/src/Controls/tests/TestCases.HostApp/Issues/Issue25599.xaml new file mode 100644 index 000000000000..4ceb61cdee8a --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue25599.xaml @@ -0,0 +1,37 @@ + + + + + + + + + +