Skip to content

Commit 6e45827

Browse files
authored
Fix crash if navigation is triggered while renaming (#7481)
* Check for null parent when setting ColumnSpan * Fix wrong merge
1 parent 1dfb5b4 commit 6e45827

File tree

3 files changed

+3
-26
lines changed

3 files changed

+3
-26
lines changed

src/Files/Views/LayoutModes/ColumnViewBase.xaml.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -375,14 +375,6 @@ private async void FileList_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
375375
// Unfocus the GridView so keyboard shortcut can be handled
376376
NavToolbar?.Focus(FocusState.Pointer);
377377
}
378-
else if (ctrlPressed && shiftPressed && (e.Key == VirtualKey.Left || e.Key == VirtualKey.Right || e.Key == VirtualKey.W))
379-
{
380-
if (!IsRenamingItem)
381-
{
382-
// Unfocus the ListView so keyboard shortcut can be handled (ctrl + shift + W/"->"/"<-")
383-
NavToolbar?.Focus(FocusState.Pointer);
384-
}
385-
}
386378
else if (e.KeyStatus.IsMenuKeyDown && shiftPressed && e.Key == VirtualKey.Add)
387379
{
388380
// Unfocus the ListView so keyboard shortcut can be handled (alt + shift + "+")

src/Files/Views/LayoutModes/DetailsLayoutBrowser.xaml.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -416,12 +416,13 @@ private async void CommitRename(TextBox textBox)
416416

417417
private void EndRename(TextBox textBox)
418418
{
419-
if (textBox != null)
419+
if (textBox != null && textBox.FindParent<Grid>() is FrameworkElement parent)
420420
{
421-
Grid.SetColumnSpan(textBox.FindParent<Grid>(), 1);
421+
Grid.SetColumnSpan(parent, 1);
422422
}
423423

424424
ListViewItem listViewItem = FileList.ContainerFromItem(RenamingItem) as ListViewItem;
425+
425426
if (textBox == null || listViewItem == null)
426427
{
427428
// Navigating away, do nothing
@@ -476,14 +477,6 @@ private async void FileList_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
476477
// Unfocus the GridView so keyboard shortcut can be handled
477478
NavToolbar?.Focus(FocusState.Pointer);
478479
}
479-
else if (ctrlPressed && shiftPressed && (e.Key == VirtualKey.Left || e.Key == VirtualKey.Right || e.Key == VirtualKey.W))
480-
{
481-
if (!IsRenamingItem)
482-
{
483-
// Unfocus the ListView so keyboard shortcut can be handled (ctrl + shift + W/"->"/"<-")
484-
NavToolbar?.Focus(FocusState.Pointer);
485-
}
486-
}
487480
else if (e.KeyStatus.IsMenuKeyDown && shiftPressed && e.Key == VirtualKey.Add)
488481
{
489482
// Unfocus the ListView so keyboard shortcut can be handled (alt + shift + "+")

src/Files/Views/LayoutModes/GridViewBrowser.xaml.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -397,14 +397,6 @@ private async void FileList_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
397397
// Unfocus the GridView so keyboard shortcut can be handled
398398
NavToolbar?.Focus(FocusState.Pointer);
399399
}
400-
else if (ctrlPressed && shiftPressed && (e.Key == VirtualKey.Left || e.Key == VirtualKey.Right || e.Key == VirtualKey.W))
401-
{
402-
if (!IsRenamingItem)
403-
{
404-
// Unfocus the ListView so keyboard shortcut can be handled (ctrl + shift + W/"->"/"<-")
405-
NavToolbar?.Focus(FocusState.Pointer);
406-
}
407-
}
408400
else if (e.KeyStatus.IsMenuKeyDown && shiftPressed && e.Key == VirtualKey.Add)
409401
{
410402
// Unfocus the ListView so keyboard shortcut can be handled (alt + shift + "+")

0 commit comments

Comments
 (0)