Skip to content
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

Fix: Fixed an issue where the home key wouldn't move focus when renaming items in List View #15225

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
12 changes: 11 additions & 1 deletion src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ protected virtual void StartRenameItem(string itemNameTextBox)

textBox.Focus(FocusState.Pointer);
textBox.LostFocus += RenameTextBox_LostFocus;
textBox.KeyDown += RenameTextBox_KeyDown;
textBox.PreviewKeyDown += RenameTextBox_KeyDown;
yaira2 marked this conversation as resolved.
Show resolved Hide resolved

int selectedTextLength = SelectedItem.Name.Length;

Expand Down Expand Up @@ -321,6 +321,16 @@ protected async void RenameTextBox_KeyDown(object sender, KeyRoutedEventArgs e)
case VirtualKey.Right:
e.Handled = (textBox.SelectionStart + textBox.SelectionLength) == textBox.Text.Length;
break;
case VirtualKey.Home:
if (!isShiftPressed)
textBox.SelectionStart = 0;
e.Handled = true;
break;
case VirtualKey.End:
if (!isShiftPressed)
textBox.SelectionStart = textBox.Text.Length;
e.Handled = true;
break;
case VirtualKey.Tab:
textBox.LostFocus -= RenameTextBox_LostFocus;

Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ protected override void EndRename(TextBox textBox)
if (textBox is not null)
{
textBox!.LostFocus -= RenameTextBox_LostFocus;
textBox.KeyDown -= RenameTextBox_KeyDown;
textBox.PreviewKeyDown -= RenameTextBox_KeyDown;
}

if (textBox is not null && textBox.Parent is not null)
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ protected override void EndRename(TextBox textBox)
if (textBox is not null)
{
textBox!.LostFocus -= RenameTextBox_LostFocus;
textBox.KeyDown -= RenameTextBox_KeyDown;
textBox.PreviewKeyDown -= RenameTextBox_KeyDown;
}

FileNameTeachingTip.IsOpen = false;
Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ override public void StartRenameItem()

textBox.Focus(FocusState.Pointer);
textBox.LostFocus += RenameTextBox_LostFocus;
textBox.KeyDown += RenameTextBox_KeyDown;
textBox.PreviewKeyDown += RenameTextBox_KeyDown;
yaira2 marked this conversation as resolved.
Show resolved Hide resolved

int selectedTextLength = RenamingItem.Name.Length;
if (!RenamingItem.IsShortcut && UserSettingsService.FoldersSettingsService.ShowFileExtensions)
Expand Down Expand Up @@ -408,7 +408,7 @@ protected override void EndRename(TextBox textBox)
if (textBox is not null)
{
textBox.LostFocus -= RenameTextBox_LostFocus;
textBox.KeyDown -= RenameTextBox_KeyDown;
textBox.PreviewKeyDown -= RenameTextBox_KeyDown;
}

FileNameTeachingTip.IsOpen = false;
Expand Down
Loading