diff --git a/src/Files.App/Views/ShellPanesPage.xaml.cs b/src/Files.App/Views/ShellPanesPage.xaml.cs index ceb126b9f2dd..ea8441e083e2 100644 --- a/src/Files.App/Views/ShellPanesPage.xaml.cs +++ b/src/Files.App/Views/ShellPanesPage.xaml.cs @@ -638,12 +638,20 @@ private void Pane_Loaded(object sender, RoutedEventArgs e) { if (sender is UIElement element) { + element.GettingFocus += Pane_GettingFocus; element.GotFocus += Pane_GotFocus; element.RightTapped += Pane_RightTapped; element.PointerPressed += Pane_PointerPressed; } } + private void Pane_GettingFocus(UIElement sender, GettingFocusEventArgs args) + { + // Workaround for https://github.com/files-community/Files/issues/15397 + if (args?.NewFocusedElement is not null && args.NewFocusedElement is not (ListViewItem or GridViewItem or ListView or GridView or TextBox)) + args.TryCancel(); + } + private void Pane_ContentChanged(object? sender, TabBarItemParameter e) { TabBarItemParameter = new() @@ -754,6 +762,7 @@ public void Dispose() { pane.Loaded -= Pane_Loaded; pane.ContentChanged -= Pane_ContentChanged; + pane.GettingFocus -= Pane_GettingFocus; pane.GotFocus -= Pane_GotFocus; pane.RightTapped -= Pane_RightTapped; pane.PointerPressed -= Pane_PointerPressed;