Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,20 @@ await Task.WhenAll(ParentShellPageInstance.SlimContentPage.SelectedItems.Select(

protected virtual void ItemManipulationModel_FocusFileListInvoked(object? sender, EventArgs e)
{
var focusedElement = (FrameworkElement)FocusManager.GetFocusedElement(MainWindow.Instance.Content.XamlRoot);
var isFileListFocused = DependencyObjectHelpers.FindParent<ListViewBase>(focusedElement) == ItemsControl;
if (!isFileListFocused)
ListViewBase.Focus(FocusState.Programmatic);
try
{
if (App.AppModel.IsMainWindowClosed)
return;

var focusedElement = (FrameworkElement)FocusManager.GetFocusedElement(MainWindow.Instance.Content.XamlRoot);
var isFileListFocused = DependencyObjectHelpers.FindParent<ListViewBase>(focusedElement) == ItemsControl;
if (!isFileListFocused)
ListViewBase.Focus(FocusState.Programmatic);
}
catch
{
// Handle exception in case the window is closed during the operation
}
}

protected virtual void ItemManipulationModel_SelectAllItemsInvoked(object? sender, EventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Views/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public async void MultitaskingControl_CurrentInstanceChanged(object? sender, Cur

// Focus the content of the selected tab item (this also avoids an issue where the Omnibar sometimes steals the focus)
await Task.Delay(100);
if (ContentPageContext?.ShellPage?.PaneHolder != null)
if (!App.AppModel.IsMainWindowClosed && ContentPageContext?.ShellPage?.PaneHolder != null)
ContentPageContext.ShellPage.PaneHolder.FocusActivePane();
}

Expand Down
Loading