Skip to content

Commit 35f7d08

Browse files
authored
Fix: Fixed issue where changing layouts focused the right pane (#17419)
1 parent 3f79e17 commit 35f7d08

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Files.App/Views/ShellPanesPage.xaml.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,12 +638,20 @@ private void Pane_Loaded(object sender, RoutedEventArgs e)
638638
{
639639
if (sender is UIElement element)
640640
{
641+
element.GettingFocus += Pane_GettingFocus;
641642
element.GotFocus += Pane_GotFocus;
642643
element.RightTapped += Pane_RightTapped;
643644
element.PointerPressed += Pane_PointerPressed;
644645
}
645646
}
646647

648+
private void Pane_GettingFocus(UIElement sender, GettingFocusEventArgs args)
649+
{
650+
// Workaround for https://github.com/files-community/Files/issues/15397
651+
if (args?.NewFocusedElement is not null && args.NewFocusedElement is not (ListViewItem or GridViewItem or ListView or GridView or TextBox))
652+
args.TryCancel();
653+
}
654+
647655
private void Pane_ContentChanged(object? sender, TabBarItemParameter e)
648656
{
649657
TabBarItemParameter = new()
@@ -754,6 +762,7 @@ public void Dispose()
754762
{
755763
pane.Loaded -= Pane_Loaded;
756764
pane.ContentChanged -= Pane_ContentChanged;
765+
pane.GettingFocus -= Pane_GettingFocus;
757766
pane.GotFocus -= Pane_GotFocus;
758767
pane.RightTapped -= Pane_RightTapped;
759768
pane.PointerPressed -= Pane_PointerPressed;

0 commit comments

Comments
 (0)