From f085a0c5f35eed3a5bd57ff704963f30c535eb20 Mon Sep 17 00:00:00 2001 From: RieBi <42877671+RieBi@users.noreply.github.com> Date: Wed, 13 Dec 2023 04:28:38 +0200 Subject: [PATCH] Fix: Fixed an issue where selection would get canceled after pressing upper arrow key (#13847) --- src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs b/src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs index f8f71f9ebe1e..5f8e8460a909 100644 --- a/src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs +++ b/src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs @@ -286,6 +286,8 @@ protected virtual async void RenameTextBox_LostFocus(object sender, RoutedEventA protected async void RenameTextBox_KeyDown(object sender, KeyRoutedEventArgs e) { var textBox = (TextBox)sender; + var isShiftPressed = (InteropHelpers.GetKeyState((int)VirtualKey.Shift) & KEY_DOWN_MASK) != 0; + switch (e.Key) { case VirtualKey.Escape: @@ -300,11 +302,13 @@ protected async void RenameTextBox_KeyDown(object sender, KeyRoutedEventArgs e) e.Handled = true; break; case VirtualKey.Up: - textBox.SelectionStart = 0; + if (!isShiftPressed) + textBox.SelectionStart = 0; e.Handled = true; break; case VirtualKey.Down: - textBox.SelectionStart = textBox.Text.Length; + if (!isShiftPressed) + textBox.SelectionStart = textBox.Text.Length; e.Handled = true; break; case VirtualKey.Left: @@ -316,7 +320,6 @@ protected async void RenameTextBox_KeyDown(object sender, KeyRoutedEventArgs e) case VirtualKey.Tab: textBox.LostFocus -= RenameTextBox_LostFocus; - var isShiftPressed = (InteropHelpers.GetKeyState((int)VirtualKey.Shift) & KEY_DOWN_MASK) != 0; NextRenameIndex = isShiftPressed ? -1 : 1; if (textBox.Text != OldItemName)