Skip to content

Commit f085a0c

Browse files
authored
Fix: Fixed an issue where selection would get canceled after pressing upper arrow key (#13847)
1 parent 6706117 commit f085a0c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Files.App/Views/Layouts/BaseGroupableLayoutPage.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ protected virtual async void RenameTextBox_LostFocus(object sender, RoutedEventA
286286
protected async void RenameTextBox_KeyDown(object sender, KeyRoutedEventArgs e)
287287
{
288288
var textBox = (TextBox)sender;
289+
var isShiftPressed = (InteropHelpers.GetKeyState((int)VirtualKey.Shift) & KEY_DOWN_MASK) != 0;
290+
289291
switch (e.Key)
290292
{
291293
case VirtualKey.Escape:
@@ -300,11 +302,13 @@ protected async void RenameTextBox_KeyDown(object sender, KeyRoutedEventArgs e)
300302
e.Handled = true;
301303
break;
302304
case VirtualKey.Up:
303-
textBox.SelectionStart = 0;
305+
if (!isShiftPressed)
306+
textBox.SelectionStart = 0;
304307
e.Handled = true;
305308
break;
306309
case VirtualKey.Down:
307-
textBox.SelectionStart = textBox.Text.Length;
310+
if (!isShiftPressed)
311+
textBox.SelectionStart = textBox.Text.Length;
308312
e.Handled = true;
309313
break;
310314
case VirtualKey.Left:
@@ -316,7 +320,6 @@ protected async void RenameTextBox_KeyDown(object sender, KeyRoutedEventArgs e)
316320
case VirtualKey.Tab:
317321
textBox.LostFocus -= RenameTextBox_LostFocus;
318322

319-
var isShiftPressed = (InteropHelpers.GetKeyState((int)VirtualKey.Shift) & KEY_DOWN_MASK) != 0;
320323
NextRenameIndex = isShiftPressed ? -1 : 1;
321324

322325
if (textBox.Text != OldItemName)

0 commit comments

Comments
 (0)