Skip to content

Commit f7666f6

Browse files
committed
Fix focus
1 parent f88c5dd commit f7666f6

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/Files.App/Actions/Navigation/NextTabAction.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace Files.App.Actions
99
internal sealed partial class NextTabAction : ObservableObject, IAction
1010
{
1111
private readonly IMultitaskingContext multitaskingContext;
12+
private readonly IContentPageContext contentPageContext = Ioc.Default.GetRequiredService<IContentPageContext>();
1213

1314
public string Label
1415
=> Strings.NextTab.GetLocalizedResource();
@@ -37,7 +38,7 @@ public async Task ExecuteAsync(object? parameter = null)
3738
await Task.Delay(500);
3839

3940
// Focus the content of the selected tab item (needed for keyboard navigation)
40-
(multitaskingContext.CurrentTabItem.TabItemContent as Control)?.Focus(FocusState.Programmatic);
41+
contentPageContext.ShellPage!.PaneHolder.FocusActivePane();
4142
}
4243

4344
private void MultitaskingContext_PropertyChanged(object? sender, PropertyChangedEventArgs e)

src/Files.App/Actions/Navigation/PreviousTabAction.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace Files.App.Actions
99
internal sealed partial class PreviousTabAction : ObservableObject, IAction
1010
{
1111
private readonly IMultitaskingContext multitaskingContext;
12+
private readonly IContentPageContext contentPageContext = Ioc.Default.GetRequiredService<IContentPageContext>();
1213

1314
public string Label
1415
=> Strings.PreviousTab.GetLocalizedResource();
@@ -40,7 +41,7 @@ public async Task ExecuteAsync(object? parameter = null)
4041
await Task.Delay(500);
4142

4243
// Focus the content of the selected tab item (needed for keyboard navigation)
43-
(multitaskingContext.CurrentTabItem.TabItemContent as Control)?.Focus(FocusState.Programmatic);
44+
contentPageContext.ShellPage!.PaneHolder.FocusActivePane();
4445
}
4546

4647
private void MultitaskingContext_PropertyChanged(object? sender, PropertyChangedEventArgs e)

src/Files.App/ViewModels/MainPageViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ private async void ExecuteNavigateToNumberedTabKeyboardAcceleratorCommand(Keyboa
391391
await Task.Delay(500);
392392

393393
// Focus the content of the selected tab item (needed for keyboard navigation)
394-
(SelectedTabItem?.TabItemContent as Control)?.Focus(FocusState.Programmatic);
394+
context.ShellPage!.PaneHolder.FocusActivePane();
395395
}
396396

397397
e.Handled = true;

0 commit comments

Comments
 (0)