Skip to content

Fix: Fixed issue where Alt-Up focused on the column header #10633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
4 changes: 0 additions & 4 deletions src/Files.App/BaseLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -464,10 +464,6 @@ public void SetSelectedItemsOnNavigation()
ItemManipulationModel.SetSelectedItems(liItemsToSelect);
ItemManipulationModel.FocusSelectedItems();
}
else if (navigationArguments is not null && navigationArguments.FocusOnNavigation)
{
ItemManipulationModel.FocusFileList(); // Set focus on layout specific file list control
}
}
catch (Exception)
{
Expand Down
15 changes: 10 additions & 5 deletions src/Files.App/Views/LayoutModes/ColumnViewBase.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,11 @@ protected override void UnhookEvents()

protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
{
if (eventArgs.Parameter is NavigationArguments navArgs)
navArgs.FocusOnNavigation = (navArgs.AssociatedTabInstance as ColumnShellPage)?.ColumnParams?.Column == 0; // Focus filelist only if first column

base.OnNavigatedTo(eventArgs);

FolderSettings.GroupOptionPreferenceUpdated -= ZoomIn;
FolderSettings.GroupOptionPreferenceUpdated += ZoomIn;
ParentShellPageInstance.FilesystemViewModel.ItemLoadStatusChanged += FilesystemViewModel_ItemLoadStatusChanged;
}

protected override void InitializeCommandsViewModel()
Expand All @@ -164,6 +162,13 @@ protected override void InitializeCommandsViewModel()
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
{
base.OnNavigatingFrom(e);
ParentShellPageInstance.FilesystemViewModel.ItemLoadStatusChanged -= FilesystemViewModel_ItemLoadStatusChanged;
}

private void FilesystemViewModel_ItemLoadStatusChanged(object sender, ViewModels.ItemLoadStatusChangedEventArgs e)
{
if (e.Status == ViewModels.ItemLoadStatusChangedEventArgs.ItemLoadStatus.Complete)
FileList.Focus(FocusState.Programmatic);
}

private void SelectionRectangle_SelectionEnded(object sender, EventArgs e)
Expand Down Expand Up @@ -381,12 +386,12 @@ private async void FileList_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
else if (e.KeyStatus.IsMenuKeyDown && (e.Key == VirtualKey.Left || e.Key == VirtualKey.Right || e.Key == VirtualKey.Up))
{
// Unfocus the GridView so keyboard shortcut can be handled
NavToolbar?.Focus(FocusState.Pointer);
this.Focus(FocusState.Pointer);
}
else if (e.KeyStatus.IsMenuKeyDown && shiftPressed && e.Key == VirtualKey.Add)
{
// Unfocus the ListView so keyboard shortcut can be handled (alt + shift + "+")
NavToolbar?.Focus(FocusState.Pointer);
this.Focus(FocusState.Pointer);
}
else if (e.Key == VirtualKey.Up || e.Key == VirtualKey.Down)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,15 @@
tui:ScrollViewerExtensions.EnableMiddleClickScrolling="{x:Bind IsMiddleClickToScrollEnabled, Mode=OneWay}"
x:FieldModifier="public"
AllowDrop="{x:Bind InstanceViewModel.IsPageTypeSearchResults, Converter={StaticResource BoolNegationConverter}, Mode=OneWay}"
AutomationProperties.AccessibilityView="Raw"
CanDragItems="True"
ContainerContentChanging="FileList_ContainerContentChanging"
DoubleTapped="FileList_DoubleTapped"
DragItemsStarting="FileList_DragItemsStarting"
DragOver="ItemsLayout_DragOver"
Drop="ItemsLayout_Drop"
IsDoubleTapEnabled="True"
IsTabStop="True"
ItemsSource="{x:Bind CollectionViewSource.View, Mode=OneWay}"
Loaded="FileList_Loaded"
PreviewKeyDown="FileList_PreviewKeyDown"
Expand Down
15 changes: 10 additions & 5 deletions src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,6 @@ protected override void InitializeCommandsViewModel()

protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
{
if (eventArgs.Parameter is NavigationArguments navArgs)
navArgs.FocusOnNavigation = true;

base.OnNavigatedTo(eventArgs);

if (FolderSettings.ColumnsViewModel is not null)
Expand All @@ -206,6 +203,7 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
FolderSettings.SortDirectionPreferenceUpdated += FolderSettings_SortDirectionPreferenceUpdated;
FolderSettings.SortOptionPreferenceUpdated += FolderSettings_SortOptionPreferenceUpdated;
ParentShellPageInstance.FilesystemViewModel.PageTypeUpdated += FilesystemViewModel_PageTypeUpdated;
ParentShellPageInstance.FilesystemViewModel.ItemLoadStatusChanged += FilesystemViewModel_ItemLoadStatusChanged;

var parameters = (NavigationArguments)eventArgs.Parameter;
if (parameters.IsLayoutSwitch)
Expand Down Expand Up @@ -235,6 +233,12 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
RootGrid_SizeChanged(null, null);
}

private void FilesystemViewModel_ItemLoadStatusChanged(object sender, ItemLoadStatusChangedEventArgs e)
{
if (e.Status == ItemLoadStatusChangedEventArgs.ItemLoadStatus.Complete)
FileList.Focus(FocusState.Programmatic);
}

private void FolderSettings_SortOptionPreferenceUpdated(object? sender, SortOption e)
{
UpdateSortIndicator();
Expand Down Expand Up @@ -289,6 +293,7 @@ protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
FolderSettings.SortDirectionPreferenceUpdated -= FolderSettings_SortDirectionPreferenceUpdated;
FolderSettings.SortOptionPreferenceUpdated -= FolderSettings_SortOptionPreferenceUpdated;
ParentShellPageInstance.FilesystemViewModel.PageTypeUpdated -= FilesystemViewModel_PageTypeUpdated;
ParentShellPageInstance.FilesystemViewModel.ItemLoadStatusChanged -= FilesystemViewModel_ItemLoadStatusChanged;
}

private void SelectionRectangle_SelectionEnded(object? sender, EventArgs e)
Expand Down Expand Up @@ -460,12 +465,12 @@ private async void FileList_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
else if (e.KeyStatus.IsMenuKeyDown && (e.Key == VirtualKey.Left || e.Key == VirtualKey.Right || e.Key == VirtualKey.Up))
{
// Unfocus the GridView so keyboard shortcut can be handled
NavToolbar?.Focus(FocusState.Pointer);
this.Focus(FocusState.Pointer);
}
else if (e.KeyStatus.IsMenuKeyDown && shiftPressed && e.Key == VirtualKey.Add)
{
// Unfocus the ListView so keyboard shortcut can be handled (alt + shift + "+")
NavToolbar?.Focus(FocusState.Pointer);
this.Focus(FocusState.Pointer);
}
else if (e.Key == VirtualKey.Down)
{
Expand Down
46 changes: 32 additions & 14 deletions src/Files.App/Views/LayoutModes/GridViewBrowser.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,16 +168,14 @@ protected override void InitializeCommandsViewModel()

protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
{
if (eventArgs.Parameter is NavigationArguments navArgs)
navArgs.FocusOnNavigation = true;

base.OnNavigatedTo(eventArgs);

currentIconSize = FolderSettings.GetIconSize();
FolderSettings.GroupOptionPreferenceUpdated -= ZoomIn;
FolderSettings.GroupOptionPreferenceUpdated += ZoomIn;
FolderSettings.LayoutModeChangeRequested -= FolderSettings_LayoutModeChangeRequested;
FolderSettings.LayoutModeChangeRequested += FolderSettings_LayoutModeChangeRequested;
ParentShellPageInstance.FilesystemViewModel.ItemLoadStatusChanged += FilesystemViewModel_ItemLoadStatusChanged;
SetItemTemplate(); // Set ItemTemplate
FileList.ItemsSource ??= ParentShellPageInstance.FilesystemViewModel.FilesAndFolders;
var parameters = (NavigationArguments)eventArgs.Parameter;
Expand All @@ -190,6 +188,13 @@ protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
base.OnNavigatingFrom(e);
FolderSettings.LayoutModeChangeRequested -= FolderSettings_LayoutModeChangeRequested;
FolderSettings.GridViewSizeChangeRequested -= FolderSettings_GridViewSizeChangeRequested;
ParentShellPageInstance.FilesystemViewModel.ItemLoadStatusChanged -= FilesystemViewModel_ItemLoadStatusChanged;
}

private void FilesystemViewModel_ItemLoadStatusChanged(object sender, ViewModels.ItemLoadStatusChangedEventArgs e)
{
if (e.Status == ViewModels.ItemLoadStatusChangedEventArgs.ItemLoadStatus.Complete)
FileList.Focus(FocusState.Programmatic);
}

private void SelectionRectangle_SelectionEnded(object? sender, EventArgs e)
Expand Down Expand Up @@ -409,17 +414,7 @@ private async void FileList_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
await QuickLookHelpers.ToggleQuickLook(ParentShellPageInstance);
}
}
else if (e.KeyStatus.IsMenuKeyDown && (e.Key == VirtualKey.Left || e.Key == VirtualKey.Right || e.Key == VirtualKey.Up))
{
// Unfocus the GridView so keyboard shortcut can be handled
NavToolbar?.Focus(FocusState.Pointer);
}
else if (e.KeyStatus.IsMenuKeyDown && shiftPressed && e.Key == VirtualKey.Add)
{
// Unfocus the ListView so keyboard shortcut can be handled (alt + shift + "+")
NavToolbar?.Focus(FocusState.Pointer);
}
else if (e.Key == VirtualKey.Up || e.Key == VirtualKey.Down)
else if (!e.KeyStatus.IsMenuKeyDown && (e.Key == VirtualKey.Up || e.Key == VirtualKey.Down))
{
// If list has only one item, select it on arrow down/up (#5681)
if (IsItemSelected)
Expand All @@ -428,6 +423,29 @@ private async void FileList_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
FileList.SelectedIndex = 0;
e.Handled = true;
}
else if (e.KeyStatus.IsMenuKeyDown)
{
if (shiftPressed && e.Key == VirtualKey.Add)
{
// Unfocus the ListView so keyboard shortcut can be handled (alt + shift + "+")
this.Focus(FocusState.Pointer);
return;
}

// Unfocus the GridView so keyboard shortcut can be handled
switch (e.Key)
{
case VirtualKey.Up:
NavToolbar?.Up.Focus(FocusState.Pointer);
return;
case VirtualKey.Left:
NavToolbar?.Back.Focus(FocusState.Pointer);
return;
case VirtualKey.Right:
NavToolbar?.Forward.Focus(FocusState.Pointer);
return;
}
}
}

protected override void Page_CharacterReceived(UIElement sender, CharacterReceivedRoutedEventArgs args)
Expand Down
1 change: 0 additions & 1 deletion src/Files.App/Views/ModernShellPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,6 @@ public class NavigationParams

public class NavigationArguments
{
public bool FocusOnNavigation { get; set; } = false;
public string? NavPathParam { get; set; } = null;
public IShellPage? AssociatedTabInstance { get; set; }
public bool IsSearchResultPage { get; set; } = false;
Expand Down