Skip to content

Commit aec16f5

Browse files
committed
Resolved merge conflicts
2 parents f922f83 + e4e6615 commit aec16f5

File tree

5 files changed

+25
-59
lines changed

5 files changed

+25
-59
lines changed

src/Files.App/Data/Contracts/IShellPanesPage.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ public interface IShellPanesPage : IDisposable, INotifyPropertyChanged
6969
/// </summary>
7070
public void FocusActivePane();
7171

72-
/// <summary>
73-
/// Locks the active pane.
74-
/// </summary>
75-
public void LockActivePane();
76-
7772
/// <summary>
7873
/// Gets open panes.
7974
/// </summary>

src/Files.App/Views/Layouts/BaseLayoutPage.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -372,13 +372,6 @@ protected virtual void BaseFolderSettings_LayoutModeChangeRequested(object? send
372372

373373
if (layoutType != ParentShellPageInstance.CurrentPageType)
374374
{
375-
// Layout changes can cause the active pane to lose focus. To prevent this,
376-
// the pane is locked here and focus is restored when file loading completes
377-
// in the RefreshItem() method in BaseLayoutPage.cs.
378-
// See https://github.com/files-community/Files/issues/15397
379-
// See https://github.com/files-community/Files/issues/16530
380-
ParentShellPageInstance!.PaneHolder.LockActivePane();
381-
382375
ParentShellPageInstance.NavigateWithArguments(layoutType, new NavigationArguments()
383376
{
384377
NavPathParam = navigationArguments!.NavPathParam,
@@ -395,6 +388,12 @@ protected virtual void BaseFolderSettings_LayoutModeChangeRequested(object? send
395388
}
396389

397390
ParentShellPageInstance.ShellViewModel.UpdateEmptyTextType();
391+
392+
// Focus on the active pane in case it was lost during the layout switch.
393+
// Allthough the focus is also set from SetSelectedItemsOnNavigation,
394+
// that is only called when switching between a Grid based layout and Details,
395+
// not between different Grid based layouts (eg. List and Cards).
396+
ParentShellPageInstance!.PaneHolder.FocusActivePane();
398397
}
399398
}
400399

@@ -513,7 +512,7 @@ protected override async void OnNavigatedTo(NavigationEventArgs e)
513512
BaseContextMenuFlyout.Opening += BaseContextFlyout_Opening;
514513
}
515514

516-
public void SetSelectedItemsOnNavigation()
515+
public async void SetSelectedItemsOnNavigation()
517516
{
518517
try
519518
{
@@ -527,12 +526,21 @@ navigationArguments.SelectItems is not null &&
527526
];
528527

529528
ItemManipulationModel.SetSelectedItems(listedItemsToSelect);
530-
ItemManipulationModel.FocusSelectedItems();
529+
530+
// Don't focus file list if TextBox is focused
531+
if (FocusManager.GetFocusedElement() is not TextBox)
532+
ItemManipulationModel.FocusSelectedItems();
531533
}
532-
else if (navigationArguments is not null && navigationArguments.FocusOnNavigation)
534+
else if (navigationArguments is not null && ParentShellPageInstance!.InstanceViewModel.FolderSettings.LayoutMode is not FolderLayoutModes.ColumnView)
533535
{
534-
// Set focus on layout specific file list control
535-
ItemManipulationModel.FocusFileList();
536+
// Delay to ensure the new layout is loaded
537+
if (navigationArguments.IsLayoutSwitch)
538+
await Task.Delay(100);
539+
540+
// Focus on the active pane in case it was lost during navigation
541+
// Don't focus file list if TextBox is focused
542+
if (FocusManager.GetFocusedElement() is not TextBox)
543+
ParentShellPageInstance!.PaneHolder.FocusActivePane();
536544
}
537545
}
538546
catch (Exception) { }
@@ -1246,14 +1254,6 @@ private void RefreshItem(SelectorItem container, object item, bool inRecycleQueu
12461254
await ParentShellPageInstance!.ShellViewModel.LoadExtendedItemPropertiesAsync(listedItem);
12471255
if (ParentShellPageInstance.ShellViewModel.EnabledGitProperties is not GitProperties.None && listedItem is IGitItem gitItem)
12481256
await ParentShellPageInstance.ShellViewModel.LoadGitPropertiesAsync(gitItem);
1249-
1250-
// Layout changes can cause the active pane to lose focus. To prevent this,
1251-
// the pane is locked in LayoutModeChangeRequested() and focus is restored here
1252-
// when file loading completes.
1253-
// See https://github.com/files-community/Files/issues/15397
1254-
// See https://github.com/files-community/Files/issues/16530
1255-
if (ParentShellPageInstance.IsCurrentPane && ParentShellPageInstance.InstanceViewModel.FolderSettings.LayoutMode is not FolderLayoutModes.ColumnView)
1256-
ItemManipulationModel.FocusFileList();
12571257
});
12581258
}
12591259
}

src/Files.App/Views/ShellPanesPage.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@
2424
</ResourceDictionary>
2525
</Page.Resources>
2626

27-
<Grid x:Name="RootGrid" />
27+
<!-- TabFocusNavigation is set to 'once' to prevent focus from auto switching to the next pane -->
28+
<Grid x:Name="RootGrid" TabFocusNavigation="Once" />
2829
</Page>

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

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -229,16 +229,6 @@ public bool IsCurrentInstance
229229
}
230230
}
231231

232-
private bool _IsActivePaneLocked;
233-
public bool IsActivePaneLocked
234-
{
235-
get => _IsActivePaneLocked;
236-
set
237-
{
238-
if (_IsActivePaneLocked != value)
239-
_IsActivePaneLocked = value;
240-
}
241-
}
242232

243233
// Events
244234

@@ -394,12 +384,6 @@ public void FocusActivePane()
394384
baseShellPage.ContentPage?.ItemManipulationModel.FocusFileList();
395385
}
396386

397-
/// <inheritdoc/>
398-
public void LockActivePane()
399-
{
400-
IsActivePaneLocked = true;
401-
}
402-
403387
/// <inheritdoc/>
404388
public IEnumerable<ModernShellPage> GetPanes()
405389
{
@@ -669,27 +653,12 @@ private void Pane_Loaded(object sender, RoutedEventArgs e)
669653
{
670654
if (sender is UIElement element)
671655
{
672-
element.GettingFocus += Pane_GettingFocus;
673656
element.GotFocus += Pane_GotFocus;
674657
element.RightTapped += Pane_RightTapped;
675658
element.PointerPressed += Pane_PointerPressed;
676659
}
677660
}
678661

679-
private void Pane_GettingFocus(UIElement sender, GettingFocusEventArgs args)
680-
{
681-
// Cancel focus attempts while the active pane is locked during layout changes.
682-
// Pane locking occurs in BaseFolderSettings_LayoutModeChangeRequested() in BaseLayoutPage.cs.
683-
// Focus is restored in RefreshItem() in BaseLayoutPage.cs when file loading completes.
684-
// See https://github.com/files-community/Files/issues/15397
685-
// See https://github.com/files-community/Files/issues/16530
686-
if (IsActivePaneLocked)
687-
{
688-
IsActivePaneLocked = false;
689-
args.TryCancel();
690-
}
691-
}
692-
693662
private void Pane_ContentChanged(object? sender, TabBarItemParameter e)
694663
{
695664
TabBarItemParameter = new()
@@ -804,7 +773,6 @@ public void Dispose()
804773
{
805774
pane.Loaded -= Pane_Loaded;
806775
pane.ContentChanged -= Pane_ContentChanged;
807-
pane.GettingFocus -= Pane_GettingFocus;
808776
pane.GotFocus -= Pane_GotFocus;
809777
pane.RightTapped -= Pane_RightTapped;
810778
pane.PointerPressed -= Pane_PointerPressed;

src/Files.App/Views/Shells/ModernShellPage.xaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
Padding="26,8,12,8"
131131
BorderBrush="{ThemeResource DividerStrokeColorDefaultBrush}"
132132
BorderThickness="0,0,0,1"
133+
IsTabStop="False"
133134
Visibility="{x:Bind ShellViewModel.ShowFilterHeader, Mode=OneWay}">
134135
<StackPanel
135136
VerticalAlignment="Center"
@@ -158,7 +159,8 @@
158159
x:Name="ItemDisplayFrame"
159160
Grid.Row="2"
160161
x:FieldModifier="public"
161-
Navigated="ItemDisplayFrame_Navigated" />
162+
Navigated="ItemDisplayFrame_Navigated"
163+
TabIndex="1" />
162164

163165
<VisualStateManager.VisualStateGroups>
164166
<VisualStateGroup x:Name="ShellBorderFocusState">

0 commit comments

Comments
 (0)