From ff8434b4a6ee35d1e449e6cc31e4267dac2ec6d8 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Thu, 7 Aug 2025 15:30:27 -0400 Subject: [PATCH 1/2] Fix: Fixed issue where changing layouts focused the right pane --- src/Files.App/Views/ShellPanesPage.xaml.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Files.App/Views/ShellPanesPage.xaml.cs b/src/Files.App/Views/ShellPanesPage.xaml.cs index ceb126b9f2dd..bc19fa7bfe25 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)) + 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; From acc26fdc9c69502887f97979defbb0a83dff44cc Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Thu, 7 Aug 2025 20:46:57 -0400 Subject: [PATCH 2/2] Update ShellPanesPage.xaml.cs --- src/Files.App/Views/ShellPanesPage.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/Views/ShellPanesPage.xaml.cs b/src/Files.App/Views/ShellPanesPage.xaml.cs index bc19fa7bfe25..ea8441e083e2 100644 --- a/src/Files.App/Views/ShellPanesPage.xaml.cs +++ b/src/Files.App/Views/ShellPanesPage.xaml.cs @@ -648,7 +648,7 @@ private void Pane_Loaded(object sender, RoutedEventArgs e) 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)) + if (args?.NewFocusedElement is not null && args.NewFocusedElement is not (ListViewItem or GridViewItem or ListView or GridView or TextBox)) args.TryCancel(); }