File tree Expand file tree Collapse file tree 4 files changed +30
-7
lines changed Expand file tree Collapse file tree 4 files changed +30
-7
lines changed Original file line number Diff line number Diff line change 11// Copyright (c) 2024 Files Community
22// Licensed under the MIT License. See the LICENSE.
33
4+ using Microsoft . UI . Xaml ;
5+ using Microsoft . UI . Xaml . Controls ;
6+
47namespace Files . App . Actions
58{
69 internal sealed class NextTabAction : ObservableObject , IAction
@@ -26,11 +29,15 @@ public NextTabAction()
2629 multitaskingContext . PropertyChanged += MultitaskingContext_PropertyChanged ;
2730 }
2831
29- public Task ExecuteAsync ( object ? parameter = null )
32+ public async Task ExecuteAsync ( object ? parameter = null )
3033 {
3134 App . AppModel . TabStripSelectedIndex = ( App . AppModel . TabStripSelectedIndex + 1 ) % multitaskingContext . TabCount ;
3235
33- return Task . CompletedTask ;
36+ // Small delay for the UI to load
37+ await Task . Delay ( 500 ) ;
38+
39+ // Refocus on the file list
40+ ( multitaskingContext . CurrentTabItem . TabItemContent as Control ) ? . Focus ( FocusState . Programmatic ) ;
3441 }
3542
3643 private void MultitaskingContext_PropertyChanged ( object ? sender , PropertyChangedEventArgs e )
Original file line number Diff line number Diff line change 11// Copyright (c) 2024 Files Community
22// Licensed under the MIT License. See the LICENSE.
33
4+ using Microsoft . UI . Xaml ;
5+ using Microsoft . UI . Xaml . Controls ;
6+
47namespace Files . App . Actions
58{
69 internal sealed class PreviousTabAction : ObservableObject , IAction
@@ -26,14 +29,18 @@ public PreviousTabAction()
2629 multitaskingContext . PropertyChanged += MultitaskingContext_PropertyChanged ;
2730 }
2831
29- public Task ExecuteAsync ( object ? parameter = null )
32+ public async Task ExecuteAsync ( object ? parameter = null )
3033 {
3134 if ( App . AppModel . TabStripSelectedIndex is 0 )
3235 App . AppModel . TabStripSelectedIndex = multitaskingContext . TabCount - 1 ;
3336 else
3437 App . AppModel . TabStripSelectedIndex -- ;
3538
36- return Task . CompletedTask ;
39+ // Small delay for the UI to load
40+ await Task . Delay ( 500 ) ;
41+
42+ // Refocus on the file list
43+ ( multitaskingContext . CurrentTabItem . TabItemContent as Control ) ? . Focus ( FocusState . Programmatic ) ;
3744 }
3845
3946 private void MultitaskingContext_PropertyChanged ( object ? sender , PropertyChangedEventArgs e )
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ public int TabStripSelectedIndex
3737
3838 if ( value >= 0 && value < MainPageViewModel . AppInstances . Count )
3939 {
40- Frame rootFrame = ( Frame ) MainWindow . Instance . Content ;
40+ var rootFrame = ( Frame ) MainWindow . Instance . Content ;
4141 var mainView = ( MainPage ) rootFrame . Content ;
4242 mainView . ViewModel . SelectedTabItem = MainPageViewModel . AppInstances [ value ] ;
4343 }
Original file line number Diff line number Diff line change 88using Microsoft . UI . Xaml . Navigation ;
99using System . Windows . Input ;
1010using Windows . System ;
11+ using Microsoft . UI . Xaml . Controls ;
1112
1213namespace Files . App . ViewModels
1314{
@@ -228,9 +229,9 @@ await Task.WhenAll(
228229
229230 // Command methods
230231
231- private void ExecuteNavigateToNumberedTabKeyboardAcceleratorCommand ( KeyboardAcceleratorInvokedEventArgs ? e )
232+ private async void ExecuteNavigateToNumberedTabKeyboardAcceleratorCommand ( KeyboardAcceleratorInvokedEventArgs ? e )
232233 {
233- int indexToSelect = e ! . KeyboardAccelerator . Key switch
234+ var indexToSelect = e ! . KeyboardAccelerator . Key switch
234235 {
235236 VirtualKey . Number1 => 0 ,
236237 VirtualKey . Number2 => 1 ,
@@ -246,8 +247,16 @@ private void ExecuteNavigateToNumberedTabKeyboardAcceleratorCommand(KeyboardAcce
246247
247248 // Only select the tab if it is in the list
248249 if ( indexToSelect < AppInstances . Count )
250+ {
249251 App . AppModel . TabStripSelectedIndex = indexToSelect ;
250252
253+ // Small delay for the UI to load
254+ await Task . Delay ( 500 ) ;
255+
256+ // Refocus on the file list
257+ ( SelectedTabItem ? . TabItemContent as Control ) ? . Focus ( FocusState . Programmatic ) ;
258+ }
259+
251260 e . Handled = true ;
252261 }
253262
You can’t perform that action at this time.
0 commit comments