Skip to content

Commit

Permalink
Fix: Home key didn't move to first character when renaming item in Li…
Browse files Browse the repository at this point in the history
…st View Layout.(files-community#15048)
  • Loading branch information
nunescostr committed Apr 19, 2024
1 parent be0ab46 commit 7fc23c5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ protected virtual void StartRenameItem(string itemNameTextBox)

textBox.Focus(FocusState.Pointer);
textBox.LostFocus += RenameTextBox_LostFocus;
textBox.KeyDown += RenameTextBox_KeyDown;
textBox.PreviewKeyDown += RenameTextBox_KeyDown;

int selectedTextLength = SelectedItem.Name.Length;

Expand Down Expand Up @@ -317,6 +317,14 @@ 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:
textBox.SelectionStart = 0;
e.Handled = true;
break;
case VirtualKey.End:
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/GridLayoutPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ override public void StartRenameItem()

textBox.Focus(FocusState.Pointer);
textBox.LostFocus += RenameTextBox_LostFocus;
textBox.KeyDown += RenameTextBox_KeyDown;
textBox.PreviewKeyDown += RenameTextBox_KeyDown;

int selectedTextLength = RenamingItem.Name.Length;
if (!RenamingItem.IsShortcut && UserSettingsService.FoldersSettingsService.ShowFileExtensions)
Expand Down

0 comments on commit 7fc23c5

Please sign in to comment.