From 3d6775d5a7204eb40163512198d7abaf1875d9ce Mon Sep 17 00:00:00 2001 From: Filippo Ferrario Date: Thu, 16 Mar 2023 23:18:03 +0100 Subject: [PATCH] Fixed: Selection isn't cleared when switching between panes --- src/Files.App/Views/PaneHolderPage.xaml | 4 ++-- src/Files.App/Views/PaneHolderPage.xaml.cs | 17 +++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Files.App/Views/PaneHolderPage.xaml b/src/Files.App/Views/PaneHolderPage.xaml index 99fa81bfb432..2c14bffa4da9 100644 --- a/src/Files.App/Views/PaneHolderPage.xaml +++ b/src/Files.App/Views/PaneHolderPage.xaml @@ -53,7 +53,7 @@ x:Name="PaneLeft" ContentChanged="Pane_ContentChanged" IsPageMainPane="True" - Loaded="PaneLeft_Loaded" + Loaded="Pane_Loaded" NavParams="{x:Bind NavParamsLeft, Mode=OneWay}" PaneHolder="{x:Bind}" /> @@ -65,7 +65,7 @@ x:Name="PaneRight" ContentChanged="Pane_ContentChanged" IsPageMainPane="False" - Loaded="PaneRight_Loaded" + Loaded="Pane_Loaded" NavParams="{x:Bind NavParamsRight, Mode=OneWay}" PaneHolder="{x:Bind}" /> diff --git a/src/Files.App/Views/PaneHolderPage.xaml.cs b/src/Files.App/Views/PaneHolderPage.xaml.cs index a9ca04efcc2f..51575bded2b0 100644 --- a/src/Files.App/Views/PaneHolderPage.xaml.cs +++ b/src/Files.App/Views/PaneHolderPage.xaml.cs @@ -330,19 +330,20 @@ public void CloseActivePane() IsRightPaneVisible = false; } - private void PaneLeft_Loaded(object sender, RoutedEventArgs e) + private void Pane_Loaded(object sender, RoutedEventArgs e) { - (sender as UIElement).GotFocus += Pane_GotFocus; - } - - private void PaneRight_Loaded(object sender, RoutedEventArgs e) - { - (sender as UIElement).GotFocus += Pane_GotFocus; + ((UIElement)sender).GotFocus += Pane_GotFocus; } private void Pane_GotFocus(object sender, RoutedEventArgs e) { - ActivePane = sender == PaneLeft ? PaneLeft : PaneRight; + var isLeftPane = sender == PaneLeft; + if (isLeftPane && (PaneRight?.SlimContentPage?.IsItemSelected ?? false)) + PaneRight.SlimContentPage.ItemManipulationModel.ClearSelection(); + else if (!isLeftPane && (PaneLeft?.SlimContentPage?.IsItemSelected ?? false)) + PaneLeft.SlimContentPage.ItemManipulationModel.ClearSelection(); + + ActivePane = isLeftPane ? PaneLeft : PaneRight; } public void Dispose()