22// Licensed under the MIT License. See the LICENSE.
33
44using Files . Shared . Helpers ;
5- using Microsoft . Extensions . Logging ;
65using Microsoft . UI . Xaml . Controls ;
76using Microsoft . UI . Xaml . Media . Imaging ;
87using Windows . Storage ;
@@ -17,17 +16,17 @@ public static class NavigationHelpers
1716 private static DrivesViewModel DrivesViewModel { get ; } = Ioc . Default . GetRequiredService < DrivesViewModel > ( ) ;
1817 private static NetworkDrivesViewModel NetworkDrivesViewModel { get ; } = Ioc . Default . GetRequiredService < NetworkDrivesViewModel > ( ) ;
1918
20- public static Task OpenPathInNewTab ( string ? path )
19+ public static Task OpenPathInNewTab ( string ? path , bool focusNewTab )
2120 {
22- return AddNewTabByPathAsync ( typeof ( PaneHolderPage ) , path ) ;
21+ return AddNewTabByPathAsync ( typeof ( PaneHolderPage ) , path , focusNewTab ) ;
2322 }
2423
2524 public static Task AddNewTabAsync ( )
2625 {
27- return AddNewTabByPathAsync ( typeof ( PaneHolderPage ) , "Home" ) ;
26+ return AddNewTabByPathAsync ( typeof ( PaneHolderPage ) , "Home" , true ) ;
2827 }
2928
30- public static async Task AddNewTabByPathAsync ( Type type , string ? path , int atIndex = - 1 )
29+ public static async Task AddNewTabByPathAsync ( Type type , string ? path , bool focusNewTab , int atIndex = - 1 )
3130 {
3231 if ( string . IsNullOrEmpty ( path ) )
3332 {
@@ -60,7 +59,8 @@ public static async Task AddNewTabByPathAsync(Type type, string? path, int atInd
6059
6160 MainPageViewModel . AppInstances . Insert ( index , tabItem ) ;
6261
63- App . AppModel . TabStripSelectedIndex = index ;
62+ if ( focusNewTab )
63+ App . AppModel . TabStripSelectedIndex = index ;
6464 }
6565
6666 public static async Task AddNewTabByParamAsync ( Type type , object tabViewItemArgs , int atIndex = - 1 )
@@ -358,7 +358,7 @@ public static async Task<bool> OpenPath(string path, IShellPage associatedInstan
358358 }
359359 else
360360 {
361- await NavigationHelpers . OpenPathInNewTab ( path ) ;
361+ await NavigationHelpers . OpenPathInNewTab ( path , true ) ;
362362 }
363363
364364 return true ;
@@ -651,7 +651,7 @@ private static async Task OpenPathAsync(bool forceOpenInNewTab, bool openFolderI
651651 {
652652 if ( forceOpenInNewTab || openFolderInNewTabSetting )
653653 {
654- await OpenPathInNewTab ( text ) ;
654+ await OpenPathInNewTab ( text , true ) ;
655655 }
656656 else
657657 {
0 commit comments